Skip to content

feat(harness): unify context construction and add optional task verification - #3275

Closed
chickenlj wants to merge 5 commits into
agentscope-ai:mainfrom
chickenlj:harness-context-redesign
Closed

chickenlj wants to merge 5 commits into
agentscope-ai:mainfrom
chickenlj:harness-context-redesign

Conversation

@chickenlj

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.0.4-SNAPSHOT

Description

Introduce a unified Harness context construction pipeline and explicit, optional task-assurance capabilities.

Changes

  • Prepare final model requests with layered System instructions, conversation history, transient task/mode projections and reference materials.
  • Apply token budgeting, tool-result offloading, candidate history compaction, tool-pair validation and metadata-only context manifests at the model boundary, including retry/fallback paths.
  • Add direct contextSource, instruction and taskContext APIs with read-only dynamic sources, timeout/failure policies and configurable optional-material selection.
  • Deduplicate Todo receipts and task projections; keep requirement proposals, requirement/verification projections and bounded verifiers opt-in.
  • Record execution observations and structured tool execution details without treating successful execution as overall task acceptance.
  • Expose observation/verification metadata through Service events.
  • Publish aligned English and Chinese user guides, distinguish persisted state from model input, and remove internal planning Markdown pages.

This does not enable a default business state machine, automatic requirement confirmation, automatic verifier orchestration or a mandatory completion gate.

Validation

Passed targeted core/harness regression tests after merging main and resolving complementary changes:

mvn -pl agentscope-harness -am test -Dtest='ReActAgentTest,ReActAgentFailoverBoundaryTest,ReActAgentHitlTest,ReActAgentReturnDirectTest,*Context*Test,*Observation*Test,HarnessAgentIntegrationExampleTest' -Dsurefire.failIfNoSpecifiedTests=false
mvn -pl agentscope-core,agentscope-harness spotless:check

Earlier targeted runs also covered TodoToolsTest, VerificationServiceTest, ShellExecuteToolTest, TaskContextStateTest and task requirement integration.

Documentation checks passed: npm test, npm run check, npm run validate and npm run broken-links.
These documentation checks were run before the latest main merge. Full repository mvn clean verify, Service/frontend test suites and live deployment validation were not run for this PR.

Checklist

  • Code has been formatted with mvn spotless:apply; relevant module formatting checks passed
  • All tests are passing (full mvn test not run; targeted results above)
  • Javadoc comments are complete and follow project conventions (not exhaustively audited)
  • Related documentation has been updated
  • Code is ready for review

…ication

Add structured execution observations, explicit task projections and bounded verifiers. Simplify context APIs and publish aligned English and Chinese user guides while removing planning documentation.
Copilot AI lite review requested due to automatic review settings September 24, 2026 07:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved security, compatibility, fallback, and context-budget issues remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity · 4 Low severity

Open (7)
What changed in this PR

Unifies Harness context construction and adds optional task observation, verification, service events, frontend presentation, tests, and bilingual documentation.

Changes:

  • Adds layered context sources, projections, budgeting, compaction, offloading, and manifests.
  • Adds persisted action observations, task requirements, and deterministic verification.
  • Updates service events, frontend presentation, tests, and documentation.
File Description
docs/​v2/​zh/​docs/​harness/​workspace.md Updates workspace context documentation.
docs/​v2/​zh/​docs/​harness/​memory.md Documents memory reference behavior.
docs/​v2/​zh/​docs/​harness/​architecture.md Documents unified context construction.
docs/​v2/​en/​docs/​harness/​workspace.md Updates workspace context documentation.
docs/​v2/​en/​docs/​harness/​memory.md Documents memory reference behavior.
docs/​v2/​en/​docs/​harness/​architecture.md Documents unified context construction.
docs/​docs.json Adds context pages to navigation.
agentscope-service/​service-dataplane/​src/​test/​java/​io/​agentscope/​builder/​web/​managed/​SessionEventMapperTest.java Tests event mappings.
agentscope-service/​service-dataplane/​src/​main/​java/​io/​agentscope/​builder/​web/​managed/​SessionEventMapper.java Persists runtime metadata events.
agentscope-service/​service-dataplane/​src/​main/​java/​io/​agentscope/​builder/​web/​catalog/​HarnessAgentBuildService.java Applies context policy overrides.
agentscope-service/​service-common/​src/​main/​java/​io/​agentscope/​builder/​web/​managed/​SessionEventTypes.java Defines event types.
agentscope-service/​frontend/​src/​features/​conversation/​eventPresentation.ts Presents observation and verification events.
agentscope-service/​frontend/​src/​features/​conversation/​eventPresentation.test.ts Tests event presentation.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​ShellExecuteToolTest.java Tests structured shell results.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​PlanModeSubagentPropagationTest.java Tests subagent plan propagation.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​observation/​StateStoreActionObserverTest.java Tests observer persistence.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​observation/​HarnessActionObservationTest.java Tests Harness observations.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspacePromptTestSupport.java Supports workspace prompt tests.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspaceContextMiddlewareSandboxPromptTest.java Tests sandbox prompts.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspaceContextMiddlewarePathBoundsTest.java Tests workspace path bounds.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspaceContextMiddlewareMemoryPromptTest.java Tests memory prompts.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​PlanModeMiddlewareTest.java Tests plan-mode projections.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​CompactionMiddlewareTest.java Tests compaction behavior.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​HarnessAgentTest.java Tests Harness agent behavior.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​HarnessAgentIntegrationExampleTest.java Tests integration context behavior.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​context/​TaskRequirementIntegrationTest.java Tests task requirement integration.
agentscope-harness/​src/​main/​resources/​io/​agentscope/​harness/​context-conventions.md Defines context conventions.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​verification/​VerificationService.java Provides verification services.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​verification/​StoredVerification.java Stores verification records.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​verification/​ShellExitCodeVerifier.java Verifies shell exit codes.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​verification/​JsonResultSchemaVerifier.java Verifies JSON result schemas.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​verification/​DeterministicVerifier.java Defines verifier contracts.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​tool/​ShellExecuteTool.java Produces shell execution details.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​observation/​StoredActionObservation.java Defines persisted observations.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​observation/​StateStoreActionObserver.java Persists action observations.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspaceContextMiddleware.java Collects workspace materials.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​ToolResultEvictionMiddleware.java Offloads large tool results.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​PlanModeMiddleware.java Projects plan-mode state.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​ContextConventionsMiddleware.java Adds framework context conventions.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​CompactionMiddleware.java Integrates request-boundary compaction.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​AtPathExpansionMiddleware.java Bounds attachment expansion.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​memory/​MemoryFlushManager.java Routes auxiliary context-aware calls.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​memory/​compaction/​ConversationCompactor.java Adds summary metadata and boundary handling.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​HarnessAgentBuilderSupport.java Propagates context configuration.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​HarnessAgent.java Integrates context capabilities.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​WorkspaceContextMaterials.java Stores workspace materials.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​TaskContextOptions.java Configures task projections.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​SourceFailurePolicy.java Defines source failure behavior.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextTokenEstimator.java Estimates context tokens.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextSources.java Loads dynamic context sources.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextSourceOptions.java Configures source behavior.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextSource.java Defines the source API.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextSelectionPolicy.java Defines material selection order.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextRequest.java Carries source request identity.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextRenderer.java Renders context materials.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextPolicy.java Defines context budgeting policy.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextModelCalls.java Routes auxiliary calls through context preparation.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextManifest.java Defines context manifests.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextItem.java Defines context metadata.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextBudgetExceededException.java Reports budget rejection.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextBlock.java Provides immutable context blocks.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​tool/​builtin/​TodoToolsTest.java Tests todo tools.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​state/​TaskContextStateTest.java Tests task state.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​observation/​ActionObservationsTest.java Tests observation lifecycle behavior.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​middleware/​TaskContextProjectionTest.java Tests task projections.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​tool/​ToolExecutor.java Integrates observation persistence.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​tool/​builtin/​TodoTools.java Adds structured todo receipts.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​tool/​builtin/​RequirementTools.java Adds requirement proposals.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​state/​TaskVerification.java Defines verification state.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​state/​TaskRequirement.java Defines requirement state.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​state/​TaskContextState.java Persists task aggregate state.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​state/​EvidenceBinding.java Binds evidence to task versions.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​observation/​ActionObserver.java Defines observation persistence.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​observation/​ActionObservations.java Implements observation lifecycles.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​observation/​ActionObservationException.java Handles observation persistence failures.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​observation/​ActionObservation.java Defines action lifecycle facts.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​middleware/​TaskReminderMiddleware.java Updates task reminders.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​middleware/​TaskContextProjection.java Builds transient task projections.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​middleware/​ModelRequestPreparer.java Defines request preparation.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​message/​ToolResultBlock.java Carries execution details.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​message/​ToolExecutionDetails.java Defines execution facts.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +39 to +40
public static String key(String actionId, boolean started) {
return "action_" + actionId + (started ? "_started" : "_settled");
Comment on lines +52 to +54
public static String key(String id) {
return "verification_" + id;
}
final GenerateOptions capturedGenOpts = b.generateOptions;
final String capturedEnvMemory = b.environmentMemory;
final MemoryConfig capturedMemoryConfig = b.memoryConfig;
final var capturedContextPolicy = b.contextPolicy;
/** Read-only dynamic context. Shared instances must be thread-safe and authorize each request. */
@FunctionalInterface
public interface ContextSource {
Mono<List<ContextBlock>> load(ContextRequest request);

## Final model input construction

Harness organizes System, conversation, task state and references at the final model-call boundary. Supply dynamic business information through contextSource. See [Context construction] for configuration, defaults and limits(/v2/en/docs/harness/context).

| Setting | Behavior |
| --- | --- |
| Default | Five-second timeout per source; reject construction on failure (FAIL) |

| 设置 | 行为 |
| --- | --- |
| 默认 | 每个来源超时 5 秒,失败则拒绝构建(FAIL) |

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Unifies Harness context construction behind one final ModelRequestPreparer boundary (HarnessContextBuilder) and adds opt-in task requirement / deterministic verification plumbing on top of a revisioned TaskContextState. The design is careful in the places that matter — the JSON-schema verifier rejects $ref/$id/$dynamicRef so it stays offline, output size is bounded, the manifest carries hashes rather than content, and failover keeps activeModel consistent. Nothing here looks blocking; the findings below are about estimation accuracy, hot-path cost, and who owns durable state.

Coverage note: this PR is 8,148 additions across 92 files, far above the 1,000-line threshold, so this pass intentionally audited the core interfaces and the new budgeting/verification/state paths (ReActAgent, ModelRequestPreparer, TaskContextState, HarnessContextBuilder, ContextSources, ContextTokenEstimator, both verifiers, CompactionMiddleware). Test bodies (~2.1k added lines) and the docs/v2 prose were only skimmed for consistency with the code, so test-quality and doc-accuracy comments from a human reviewer are still needed.

Findings

  • [Warning] ContextTokenEstimator.java:53 — length/2.5 under-counts CJK text by ~2.5x, so the budget gate is loosest exactly when a zh session is nearest the provider limit.
  • [Warning] HarnessContextBuilder.java:561 — two different allowances for an unknown context window (64000 here vs CompactionConfig.FALLBACK_TRIGGER_TOKENS = 160_000 in CompactionMiddleware.onReasoning).
  • [Warning] HarnessContextBuilder.java:246 — omission loop rebuilds and re-estimates the whole request per candidate; multiplied again by retries/failover because prepare() runs per subscription.
  • [Warning] HarnessContextBuilder.java:363 — clear()/addAll() on the live context is non-atomic for concurrent readers, and preparation commits durable history even when the attempt never reaches the provider.
  • [Warning] CompactionMiddleware.java:116 — durable compaction now has two owners (prepare/onReasoning vs the context builder); suggest making single ownership explicit.
  • [Warning] ReActAgent.java:857 — defaultSessionId substitution turns the observer's "session identity required" rejection into silently shared attribution across concurrent calls.
  • [Info] ReActAgent.java:4414 — the failover branch publishes a nested ModelCallStartEvent/ModelCallEndEvent pair with a fresh call id and null usage.

Two smaller things worth a look while you are in here: TaskContextState.equals/hashCode now fold the mutable revision into value equality (and are not synchronized while every mutator is), and propose() is the only mutator without an expectedRevision argument, so it sits outside the optimistic-concurrency contract the rest of the class documents.


Automated review by github-manager-bot

}

private static long text(String value) {
return value == null ? 0 : (long) Math.ceil(value.length() / 2.5);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] ceil(length / 2.5) is calibrated for Latin text. For CJK, mainstream tokenizers land near one token per character, so a Chinese conversation is under-counted by roughly 2.5x — and under-counting is the dangerous direction for a budget gate: HarnessContextBuilder keeps a request when estimate(...) <= limit, so the provider then rejects it with a context-length error and the failure surfaces as an opaque model error instead of a local budget decision. This project ships first-class zh documentation and targets DashScope/Qwen models, so CJK-heavy sessions are a default workload, not an edge case.

Could text() weight non-ASCII code points near 1 token each (a codePoints() split on the CJK ranges is enough)? Estimate.method is already a versioned tag, so moving to e.g. mixed-text-cjk-aware-v2 keeps earlier manifests reproducible while the ratio is fixed.

policy.safetyMarginTokens() > 0
? policy.safetyMarginTokens()
: window > 0 ? Math.max(1, window / 50) : 1024;
long limit = window > 0 ? Math.max(0, window - output - safety) : 64000;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] There are now two different allowances for the same condition — "the model does not report a context window". Here the input limit becomes a flat 64000 tokens (minus a 1024 safety margin and a 4096 output reservation), while CompactionMiddleware.onReasoning uses CompactionConfig.FALLBACK_TRIGGER_TOKENS, which is 160_000. When a request falls into the "unknown window" branch, the two stages disagree by 2.5x about what fits, so trimming/omission decisions and compaction decisions are made against different numbers, and the manifest's limit no longer explains why compaction did or did not run.

Could both stages read one shared value (ContextPolicy.unknownWindowTokens(), or reuse CompactionConfig.FALLBACK_TRIGGER_TOKENS), plus a one-time log.warn when the fallback is used? Then a deployment with a small local/Ollama model has a single knob to set instead of two implicit constants.

throw new IllegalArgumentException("Invalid context omission candidate: " + id);
}
for (String id : order) {
if (policy.estimator().estimate(project(current, snapshot)).tokens() <= limit)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] This loop re-runs project(current, snapshot) and a full estimate for every omission candidate, so the entire request is rebuilt and re-tokenized O(candidates) times per model call. project() walks and rebuilds the whole message list via TaskContextProjection.project(...), and the estimator serializes every tool schema (JsonUtils.toJson(tool), line 45) on each pass — so one iteration is already a full serialization pass over messages and tools. Because ModelRequestPreparer#prepare is documented as called anew on subscription, retries and the failover path multiply this again.

Since only one item changes per iteration, an incremental estimate (subtract the omitted item's own marginal cost) or a binary search over the prefix of order that satisfies the budget keeps this linear. Same remark for the messages().equals(...) deep comparisons at 226/270 — a size check first would avoid comparing a large history element-by-element on every transform.

"History changed during context preparation");
}
if (!candidate.history().equals(original)) {
state.contextMutable().clear();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] Two related concerns about committing the durable history from the preparation stage:

  1. The swap is not atomic. clear() followed by addAll() on the live list is observable as an empty context by any concurrent reader (getMemory(), session serialization, an interrupt path). The equals(original) guard at 355 protects against losing a concurrent append, but it is a check-then-act and does not protect the intermediate state. The task/plan check right above at 343 shows the right instinct — the context swap needs the same single critical section.
  2. Preparation has a durable side effect. prepare() is called anew on subscription (retries) and again on failover from ReActAgent.modelForCall, so history can be rewritten for an attempt that never reached the provider — the dropped pre-compaction messages are gone without a model turn having been produced.

Suggest a copy-and-swap on AgentState (one atomic replace guarded by an expected-value check) and either documenting explicitly that context preparation commits durable changes, or returning the candidate history so the agent loop commits it once the call is accepted.

.map(
candidate -> {
if (state != null
&& state.contextMutable().equals(original)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] After this change, compacting durable history has two owners. prepare(...) still commits here (applyToContext) whenever it runs through onReasoning, and HarnessContextBuilder.compileSnapshot(...) now commits the same kind of change itself (builder line 363) using a budget derived from inputLimit(...). In HarnessAgent.Builder the hook is created once and handed to the context builder (new HarnessContextBuilder(contextPolicy, compactionHook, ...)), and I could not find a middleware(compactionHook) registration, so today only the builder path runs — but CompactionMiddleware is still a public MiddlewareBase and getCompactionHook() is public API, so any agent (or a future default wiring) that puts it back into the chain gets two compaction passes per reasoning step under two different allowances, with history_compaction recorded once or twice depending on ordering.

Could single ownership be made explicit? Either drop onReasoning (keeping prepareCandidate as the only entry point) or have onReasoning no-op when a ModelRequestPreparer is installed, plus one integration test asserting exactly one compaction pass per reasoning step.

String sid = base.getSessionId();
run =
RuntimeContext.builder(base)
.sessionId(sid == null || sid.isBlank() ? defaultSessionId : sid)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] Substituting defaultSessionId here changes a missing session identity from rejected to silently shared. defaultSessionId is derived from the builder name (falling back to "ReActAgent"), i.e. per agent instance, not per call — while StateStoreActionObserver.record(...) explicitly throws IllegalArgumentException("Action observation requires a session identity") for a null/blank session. Once an observer is installed this path guarantees that guard can never fire: every call(msgs) that omits a RuntimeContext — the common embedded/single-turn shape — writes its immutable start/settled records under one shared session slot, keyed only by actionId.

The state store is addressed by (userId, sessionId, key), so this is exactly the session-isolation dimension the distribution module promises. Suggest leaving the session id untouched (so the observer keeps rejecting ambiguous records loudly), or making Builder#actionObserver(...) require callers to supply a session identity explicitly.

+ " request")))
.flatMapMany(
prepared -> {
ModelCallStartEvent start =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Info] The failover branch publishes a second ModelCallStartEvent keyed by a freshly generated callId, while the enclosing preparedModelCallStream(...) has already emitted the start for the outer replyId (modelCallStart(replyId)) and still emits its own terminal endEvents for it. Consumers that open/close an assistant turn per MODEL_CALL_START/MODEL_CALL_END — the dataplane SessionEventMapper is one — see an extra nested start/end pair whose id appears nowhere else in the stream, with null usage on the end event, and contextManifest ends up attached to the inner event rather than the one that opened the block.

If one boundary per provider attempt is the intent, a comment here plus a line in the event docs is enough; otherwise reusing the outer call id keeps the start/end/manifest triple single-sourced.

@oss-maintainer

Copy link
Copy Markdown
Collaborator

⚠️ Merge conflict detected

This PR currently conflicts with main and cannot be merged (head 52f2491550). Please rebase or merge main into harness-context-redesign and resolve the conflicts:

git fetch origin
git checkout harness-context-redesign
git rebase origin/main
# resolve conflicts, then:
git push --force-with-lease

This is a one-time reminder. Feel free to @mention me for a re-review after the conflicts are resolved.


Automated notification by github-manager-bot

@chickenlj chickenlj closed this Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants