Skip to content

Commit aa8c0e5

Browse files
committed
Merge branch 'fix/unstable-computehash' of https://github.com/vlooong/agentscope-java into fix/unstable-computehash
2 parents 32c03f1 + 8af889f commit aa8c0e5

1,527 files changed

Lines changed: 156814 additions & 8311 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ build/
3737
.flattened-pom.xml
3838
**/dependency-reduced-pom.xml
3939

40+
### Python
41+
__pycache__/
42+
*.py[cod]
43+
*$py.class
44+
*.egg-info/
45+
4046
### Docs
4147
docs/_build
48+
.venv/
4249

4350

4451
# vibe coding
@@ -50,10 +57,28 @@ CLAUDE.md
5057
##Log
5158
logs/
5259

53-
## boba-tea-shop example
60+
## Frontend (all frontend/ directories across examples and extensions)
61+
# Dependencies
62+
**/frontend/node_modules/
63+
# Build output
64+
**/frontend/dist/
65+
**/frontend/build/
66+
**/frontend/.output/
67+
# Vite / bundler caches
68+
**/frontend/.vite/
69+
**/frontend/.cache/
70+
**/frontend/.parcel-cache/
71+
# Type-check / tsc output
72+
**/frontend/*.tsbuildinfo
73+
# Env files (may contain secrets)
74+
**/frontend/.env.local
75+
**/frontend/.env.*.local
76+
# Coverage
77+
**/frontend/coverage/
78+
# Storybook
79+
**/frontend/storybook-static/
80+
# boba-tea-shop: generated static assets served by the supervisor-agent
5481
**/boba-tea-shop/supervisor-agent/**/static/
55-
**/boba-tea-shop/**/node_modules/
56-
**/boba-tea-shop/**/dist/
5782

5883
##agentscope
5984
.agentscope/

.licenserc.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ header:
7272
- 'CNAME'
7373
- 'Jenkinsfile'
7474
- '**/vendor/**'
75+
- '**/docs/**'
7576
- '**/.prettierrc'
77+
- 'agentscope-examples/**/frontend/**'
78+
- '**/Dockerfile'
79+
- '**/src/main/resources/**'
80+
- '**/src/test/resources/**'
7681
comment: on-failure
7782

7883
license-location-threshold: 130

agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,28 @@ private Mono<PostActingEvent> notifyPostActingHook(
828828
protected Mono<Msg> summarizing() {
829829
log.debug("Maximum iterations reached. Generating summary...");
830830

831+
// Handle pending tool calls that were not completed before max iterations
832+
if (hasPendingToolUse()) {
833+
List<ToolUseBlock> pendingTools = extractPendingToolCalls();
834+
log.warn(
835+
"Max iterations reached with {} pending tool calls. Adding error results.",
836+
pendingTools.size());
837+
838+
for (ToolUseBlock toolUse : pendingTools) {
839+
ToolResultBlock errorResult =
840+
buildErrorToolResult(
841+
toolUse.getId(),
842+
"Tool execution cancelled because maximum iterations limit ("
843+
+ maxIters
844+
+ ") was reached");
845+
846+
Msg errorResultMsg =
847+
ToolResultMessageBuilder.buildToolResultMsg(
848+
errorResult, toolUse, getName());
849+
memory.addMessage(errorResultMsg);
850+
}
851+
}
852+
831853
List<Msg> messageList = prepareSummaryMessages();
832854
GenerateOptions generateOptions = buildGenerateOptions();
833855

agentscope-core/src/main/java/io/agentscope/core/agent/AgentBase.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,11 +906,20 @@ private Flux<Event> createEventStream(StreamOptions options, Supplier<Mono<Msg>>
906906
// Add temporary hook
907907
addHook(streamingHook);
908908

909+
// Bus that subagent tools use to push child events
910+
// into this parent sink without an extra Flux layer.
911+
SubagentEventBus bus = sink::next;
912+
909913
// Use Mono.defer to ensure trace context propagation
910914
// while maintaining streaming hook functionality
911915
Mono.defer(() -> callSupplier.get())
912916
.contextWrite(
913-
context -> context.putAll(ctxView))
917+
context ->
918+
context.put(
919+
SubagentEventBus
920+
.CONTEXT_KEY,
921+
bus)
922+
.putAll(ctxView))
914923
.doFinally(
915924
signalType -> {
916925
// Remove temporary hook

agentscope-core/src/main/java/io/agentscope/core/agent/Event.java

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.fasterxml.jackson.annotation.JsonCreator;
1919
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
20+
import com.fasterxml.jackson.annotation.JsonInclude;
2021
import com.fasterxml.jackson.annotation.JsonProperty;
2122
import io.agentscope.core.message.Msg;
2223

@@ -46,27 +47,60 @@
4647
* }</pre>
4748
*/
4849
@JsonIgnoreProperties(ignoreUnknown = true)
50+
@JsonInclude(JsonInclude.Include.NON_NULL)
4951
public class Event {
5052

5153
private final EventType type;
5254
private final Msg message;
5355
private final boolean isLast;
5456

5557
/**
56-
* Creates a new event.
58+
* Identifies the originating (sub)agent when this event was emitted by a nested subagent
59+
* during a parent {@code stream()} call. {@code null} for events emitted by the top-level
60+
* agent itself.
61+
*/
62+
private final EventSource source;
63+
64+
/**
65+
* Creates a new event (top-level agent — no source).
5766
*
5867
* @param type The event type (REASONING, TOOL_RESULT, etc.)
5968
* @param message The message content
6069
* @param isLast Whether this is the last/complete message for this event
6170
*/
71+
public Event(EventType type, Msg message, boolean isLast) {
72+
this(type, message, isLast, null);
73+
}
74+
75+
/**
76+
* Creates a new event with optional source.
77+
*
78+
* @param type The event type
79+
* @param message The message content
80+
* @param isLast Whether this is the last/complete message
81+
* @param source The originating subagent, or {@code null} for the top-level agent
82+
*/
6283
@JsonCreator
6384
public Event(
6485
@JsonProperty("type") EventType type,
6586
@JsonProperty("message") Msg message,
66-
@JsonProperty("isLast") boolean isLast) {
87+
@JsonProperty("isLast") boolean isLast,
88+
@JsonProperty("source") EventSource source) {
6789
this.type = type;
6890
this.message = message;
6991
this.isLast = isLast;
92+
this.source = source;
93+
}
94+
95+
/**
96+
* Returns a copy of this event with the given source attached. The original event is not
97+
* modified (immutable copy).
98+
*
99+
* @param source the originating subagent descriptor
100+
* @return new Event with {@code source} set
101+
*/
102+
public Event withSource(EventSource source) {
103+
return new Event(this.type, this.message, this.isLast, source);
70104
}
71105

72106
/**
@@ -137,6 +171,19 @@ public boolean isLast() {
137171
return isLast;
138172
}
139173

174+
/**
175+
* Returns the originating subagent descriptor, or {@code null} if this event was emitted by
176+
* the top-level agent.
177+
*
178+
* <p>Consumers can use this to route subagent events to the correct UI card or log channel
179+
* without needing out-of-band metadata.
180+
*
181+
* @return the event source, or {@code null} for the top-level agent
182+
*/
183+
public EventSource getSource() {
184+
return source;
185+
}
186+
140187
/**
141188
* Get the message ID (delegates to {@link Msg#getId()}).
142189
*
@@ -151,6 +198,11 @@ public String getMessageId() {
151198

152199
@Override
153200
public String toString() {
201+
if (source != null) {
202+
return String.format(
203+
"Event{type=%s, isLast=%s, msgId=%s, contentBlocks=%d, source=%s}",
204+
type, isLast, message.getId(), message.getContent().size(), source);
205+
}
154206
return String.format(
155207
"Event{type=%s, isLast=%s, msgId=%s, contentBlocks=%d}",
156208
type, isLast, message.getId(), message.getContent().size());

0 commit comments

Comments
 (0)