Skip to content

fix(harness): harden context management and recovery - #4399

Merged
oss-maintainer merged 8 commits into
agentscope-ai:mainfrom
chickenlj:feat/context-windows-and-failure-metadata2
Nov 25, 2026
Merged

oss-maintainer merged 8 commits into
agentscope-ai:mainfrom
chickenlj:feat/context-windows-and-failure-metadata2

Conversation

@chickenlj

@chickenlj chickenlj commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

This PR brings together the context-management and recovery changes from feat/context-windows-and-failure-metadata2.

  • Update model context-window resolution and learn usable limits from provider overflow responses.
  • Keep overflow recovery within the current reasoning step for both the native Thread journal and the legacy state store. Preserve structured output and avoid replaying tools that already ran.
  • Carry the latest genuine user input verbatim through regular compaction and bound workspace materials, tool output, and history reads while retaining recovery references.
  • Preserve subagent completion delivery across reasoning rounds, avoid duplicate result injection, and maintain compatibility with the existing delivery paths.
  • Add structured tool failure metadata and feedback for repeated failures. Keep memory opt-in and preserve provenance when extracting and consolidating memory.
  • Update the English and Chinese Harness guides and add regression coverage. The existing tool exposure policy remains in place.

Validation and merge status

  • Merged main at ea2aed132 into this branch in 584a073a7 and resolved all 14 conflicts. GitHub reports the head is mergeable.
  • Full mvn -B -T1C -fae clean verify passed across 114 modules in a shell without provider credentials. Core reported 3,550 tests with 11 skipped, and Harness reported 2,263 with 36 skipped. Both reported zero failures and errors.
  • npm test, npm run validate, npm run broken-links, and git diff --check origin/main...HEAD passed.

Checklist

  • Rechecked formatting against the integrated branch
  • Reran affected tests locally
  • Review GitHub CI
  • Updated related documentation
  • Ready for review

- Resolve context windows by prefix family per provider, add xAI Grok, and
  tolerate vendor-prefixed ids such as kimi/kimi-k3.
- Learn unknown windows from provider overflow errors and share them with
  the compaction trigger and the input limit.
- Surface tool error kind/metadata, add a repeated-failure guard, and update
  the affected harness tools and docs.
Long-term memory is now opt-in, so a builder that never enables it runs no
inline memory flush and the summary-replay test never observes a SUMMARY
model call. Enable it in that test and stop describing the flush as default
in the adapter.
Keep rejected tools indistinguishable and guide repeated calls without changing execution outcomes, while making partial subagent results and truncated shell output actionable.

Constraint: Preserve existing permissions, budgets, and task protocols.
Confidence: high
Address kernel-level failure modes found in bench trajectories so agents
recover from bounded outputs, stale ownership and incomplete memory work
instead of looping or losing facts.

- RepeatedFailureGuard: initialize per invocation at ON_AGENT_STATE_READY
  and track ownership with a private InvocationToken that survives Core
  RuntimeContext copies; missing and ungranted tools stay indistinguishable.
- ReActAgent/MiddlewareBase: deliver producer events and post-acting
  feedback to middleware consistently.
- Shell: bounded capture with archive, raw digest and cancellation cleanup.
- Subagents: dynamic snapshots, owner-registry gating and context-aware
  gateway exposure with materializer recovery.
- Thread history pagination, memory_get long-line recovery, and memory
  commit veto for incomplete flush/consolidation.
- Docs (EN/ZH) updated for middleware, harness architecture, context,
  filesystem, memory, session-log and subagent behavior.

Constraint: Preserve agentscope-ai#3500 - missing vs ungranted tools indistinguishable
Constraint: Kernel only; adapter, PI, H2/H3 and business rules untouched
Rejected: Ctx-reference ownership | Core copies RuntimeContext mid-call
Confidence: high
Scope-risk: moderate
Not-tested: Real Java 17 runtime (built with JDK 21, release 17)
Not-tested: Windows/Linux, e2e group, GitSkillRepositoryTest, WeixinLiveSmokeTest
Not-tested: Real model semantics for memory pipeline; historical bench replay
Page large skill catalogs and omit opaque revisions from model-visible context. Respect memory opt-in during compaction and restore dynamic subagent routing on resumed calls.

Preserve asynchronous task results and failure details, and clarify tool recovery guidance. Cover the changes with regression tests and update the English and Chinese Harness docs.
@mintlify

mintlify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit ebe053f.

Approve preview

@chickenlj
chickenlj marked this pull request as ready for review November 25, 2026 08:45
Copilot AI balanced review requested due to automatic review settings November 25, 2026 08:45

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.

🟡 Changes recommended

Cold recovery reloads parent declarations in the child’s session namespace, which can prevent exposed-child recovery after restart or select the wrong declaration.

4 open issues
What changed in this PR

This PR hardens context management and recovery across Core, Harness, and model integrations, aiming to preserve completed work and useful evidence during long-running agent tasks.

Changes:

  • Improves model-window resolution, overflow recovery, compaction, and bounded context views.
  • Strengthens subagent result delivery and recovery, structured tool failures, and opt-in memory handling.
  • Adds regression coverage, updates Harness guides, and corrects the asynchronous subagent example.

Validation here was limited to source inspection; tests and builds were not rerun.

File Description
docs/​dev/​zh/​docs/​harness/​workspace.md Documents opt-in memory and independent controls.
docs/​dev/​zh/​docs/​harness/​subagent.md Explains scoped recovery and result delivery.
docs/​dev/​zh/​docs/​harness/​skill.md Documents skill discovery and pagination.
docs/​dev/​zh/​docs/​harness/​session-log.md Adds history pagination guidance.
docs/​dev/​zh/​docs/​harness/​filesystem.md Explains output previews, archives, and digests.
docs/​dev/​zh/​docs/​harness/​context.md Updates compaction and recovery semantics.
docs/​dev/​zh/​docs/​harness/​architecture.md Documents memory defaults and repeated-failure feedback.
docs/​dev/​en/​docs/​harness/​workspace.md Documents opt-in memory and independent controls.
docs/​dev/​en/​docs/​harness/​subagent.md Explains scoped recovery and result delivery.
docs/​dev/​en/​docs/​harness/​skill.md Documents skill discovery and pagination.
docs/​dev/​en/​docs/​harness/​session-log.md Adds history pagination guidance.
docs/​dev/​en/​docs/​harness/​memory.md Describes bounded reads and provenance-preserving memory.
docs/​dev/​en/​docs/​harness/​filesystem.md Explains output previews, archives, and digests.
docs/​dev/​en/​docs/​harness/​context.md Updates context budgets and recovery semantics.
docs/​dev/​en/​docs/​harness/​architecture.md Documents memory defaults and repeated-failure feedback.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tools/​HarnessAgentToolsConfigTest.java Explicitly enables memory for configuration tests.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​WebToolsTest.java Checks web failure metadata.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​WaitAsyncResultsToolTest.java Covers complete barrier output and cancellation wording.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​ToolResultAssertions.java Adds shared metadata assertions.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​TaskToolTest.java Tests full partial results and error details.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​MemorySearchToolTest.java Tests bounded search output and guidance.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​FilesystemToolTest.java Tests filesystem error classification.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​AgentSpawnToolResultStateTest.java Covers completion reasons and document preservation.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​AgentSpawnToolPromotionTest.java Tests timeout-promoted result preservation.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​AgentSpawnToolKeyTest.java Supplies identity-bound state for handle tests.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​AgentSpawnToolForceSyncTest.java Aligns synchronous delegation state with caller identity.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​AgentSpawnToolFollowUpSessionTest.java Adds parent state to follow-up fixtures.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​AgentSpawnToolExecutionHostTest.java Adds identity-bound execution-host state.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​tool/​AgentSpawnToolDelegationSemanticsTest.java Updates delegation-description assertions.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​SubagentFactoryDeclarationTest.java Aligns reuse and isolation tests with parent state.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​subagent/​task/​WorkspaceTaskRepositoryDeliveryTest.java Tests restored cancellation, errors, and full results.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​skill/​runtime/​SkillRuntimeTest.java Tests compact catalogs and scoped discovery.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​HarnessSkillMiddlewareContextIsolationTest.java Covers unavailable and externally replaced loaders.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​ContextConventionsResetOrderTest.java Checks retry, quotation, and permission guidance.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​ManagedSubagentBoundaryTest.java Tests inherited web-tool restrictions.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​HarnessAgentIntegrationExampleTest.java Explicitly enables memory in the integration fixture.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​context/​LearnedContextWindowsTest.java Covers overflow-window parsing and retention.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​context/​HarnessContextBuilderTest.java Checks bounded history and offloaded tool output.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​context/​HarnessContextBudgetTest.java Tests learned-window budget calculation.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​context/​ContextRendererTest.java Checks semantic versus content-hash revisions.
agentscope-harness/​src/​main/​resources/​io/​agentscope/​harness/​context-conventions.md Adds evidence, safe-retry, and quotation guidance.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​tool/​WebTools.java Classifies HTTP and request failures.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​tool/​WaitAsyncResultsTool.java Improves barrier error and empty-result formatting.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​tool/​TaskTool.java Clarifies output retrieval and missing error text.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​tool/​MemorySaveTool.java Adds provenance guidance and validation metadata.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​subagent/​task/​WorkspaceTaskRepository.java Persists cancellation and consistent primary errors.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​skill/​runtime/​SkillRuntime.java Adds control over compact catalog rendering.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​skill/​runtime/​SkillPromptBuilder.java Renders compact, paginated skill indexes.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​skill/​runtime/​SkillLoadTool.java Adds scoped skill search and pagination.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspaceContextMiddleware.java Adds memory provenance and data-handling guidance.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​InboxMiddleware.java Retains deferred task hints across reasoning retries.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​HarnessSkillMiddleware.java Gates compact catalogs on loader availability.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​DynamicSubagentsMiddleware.java Installs call-scoped declaration snapshots.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​CompactionMiddleware.java Extends overflow recovery and gates memory extraction.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​memory/​MemoryFlushManager.java Rejects incomplete extraction and adds provenance rules.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​memory/​MemoryConsolidator.java Strengthens stream validation and consolidation guidance.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​memory/​compaction/​ConversationCompactor.java Carries the latest genuine user input through compaction.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​HarnessAgentBuilderSupport.java Propagates memory and tool controls to children.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​gateway/​SubagentGatewayBridge.java Adds context-aware exposure with compatibility delegation.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​gateway/​HarnessGateway.java Persists user identity for exposed-child recovery.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​gateway/​GatewayBootstrap.java Uses caller context during child materialization.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​filesystem/​model/​ExecuteResponse.java Adds an optional captured-output digest.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​HarnessContextBuilder.java Applies learned windows and orders pending deliveries.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextRenderer.java Omits default content hashes from model-facing tags.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​context/​ContextItem.java Shares revision hashing with the renderer.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai/​src/​test/​java/​io/​agentscope/​extensions/​model/​openai/​compat/​deepseek/​DeepSeekModelProviderTest.java Updates window expectations and prefix-resolution coverage.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai/​src/​main/​java/​io/​agentscope/​extensions/​model/​openai/​OpenAIModelProvider.java Delegates window resolution to the model builder.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai/​src/​main/​java/​io/​agentscope/​extensions/​model/​openai/​OpenAIChatModel.java Uses shared context-window resolution.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai/​src/​main/​java/​io/​agentscope/​extensions/​model/​openai/​compat/​minimax/​MiniMaxModelProvider.java Delegates window resolution to the model builder.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai/​src/​main/​java/​io/​agentscope/​extensions/​model/​openai/​compat/​kimi/​KimiModelProvider.java Delegates window resolution to the model builder.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai/​src/​main/​java/​io/​agentscope/​extensions/​model/​openai/​compat/​glm/​GLMModelProvider.java Delegates window resolution to the model builder.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai/​src/​main/​java/​io/​agentscope/​extensions/​model/​openai/​compat/​deepseek/​DeepSeekModelProvider.java Delegates window resolution to the model builder.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai-official/​src/​test/​java/​io/​agentscope/​extensions/​model/​openaiofficial/​OpenAIResponsesChatModelTest.java Aligns fallback expectations with shared resolution.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-openai-official/​src/​main/​java/​io/​agentscope/​extensions/​model/​openaiofficial/​OpenAIResponsesChatModel.java Uses shared context-window resolution.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-gemini/​src/​main/​java/​io/​agentscope/​extensions/​model/​gemini/​GeminiChatModel.java Uses shared context-window resolution.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-dashscope/​src/​main/​java/​io/​agentscope/​extensions/​model/​dashscope/​DashScopeChatModel.java Uses shared context-window resolution.
agentscope-extensions/​agentscope-extensions-model/​agentscope-extensions-model-anthropic/​src/​main/​java/​io/​agentscope/​extensions/​model/​anthropic/​AnthropicChatModel.java Uses shared context-window resolution.
agentscope-examples/​documentation/​src/​main/​java/​io/​agentscope/​examples/​documentation2/​harness/​async/​AsyncSubagentExample.java Shares the message bus and invokes through the gateway.
agentscope-durable/​durable-adapters/​durable-adapter-harness-agentscope/​src/​test/​java/​io/​agentscope/​durable/​agentscope/​AgentScopeAdapterTest.java Explicitly enables memory for inline-flush coverage.
agentscope-durable/​durable-adapters/​durable-adapter-harness-agentscope/​src/​main/​java/​io/​agentscope/​durable/​agentscope/​AgentScopeAdapter.java Clarifies the comment describing optional memory work.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​tool/​ToolExecutorTest.java Checks executor failure classifications.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​middleware/​ActivePointsResolverTest.java Tests event-observer participation and opt-out.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​message/​ToolResultBlockTest.java Tests metadata merging and serialization.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​message/​ToolErrorMetadataTest.java Covers metadata defaults, overrides, and immutability.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​agent/​TruncatedToolCallIntegrityTest.java Verifies truncated-call metadata reaches events.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​agent/​ReActAgentStructuredOutputTest.java Tests structured-output argument failure metadata.
agentscope-core/​src/​test/​java/​io/​agentscope/​core/​agent/​CapabilityGrantIntegrationTest.java Checks indistinguishable missing and ungranted tool errors.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​tool/​ToolExecutor.java Adds structured lookup and validation failures.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​middleware/​MiddlewareBase.java Defines synchronous producer-side event observation.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​message/​ToolResultBlock.java Adds failure keys and immutable metadata merging.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​message/​ToolErrorMetadata.java Introduces failure metadata construction helpers.
agentscope-core/​src/​main/​java/​io/​agentscope/​core/​message/​ToolErrorKind.java Defines stable failure kinds and retry defaults.

Review effort: Balanced

Comment on lines +338 to +339
DefaultAgentManager scoped = ha.getSubagentAgentManager(rc);
Optional<Agent> agent = scoped.createAgentIfPresent(agentId, rc);
Comment on lines +119 to +121
- On conflict, keep both entries with their sources and dates. Replace an older \
entry only when the newer entry names its source and date; otherwise mark the \
conflict instead of silently choosing one side.
CompactionConfig.builder()
.triggerMessages(1)
.keepMessages(1)
.keepMessages(recoveryTailSize(before))
Comment on lines +210 to +211
new SkillPromptBuilder()
.renderIndex(matches, number.intValue(), query)));
@oss-maintainer
oss-maintainer merged commit d29103b into agentscope-ai:main Nov 25, 2026
7 checks passed
@chickenlj
chickenlj deleted the feat/context-windows-and-failure-metadata2 branch November 25, 2026 10:30
xseruer added a commit to xseruer/agentscope-java that referenced this pull request Nov 26, 2026
updateStatus now reads the record back after writing: WorkspaceManager
swallows storage failures, so a normal return from the write says
nothing about what the task exposes afterwards.

The settlement callback therefore never announces a terminal status that
is not on record. A completed result exists only in memory, so it is
handed over with the on-record status instead of being dropped (agentscope-ai#4399
requires the result to survive a failed record write); an unrecorded
failure or cancellation has nothing to deliver and is not announced.
xzxiaoshan added a commit that referenced this pull request Nov 26, 2026
…#4435)

## Background

Swept the last 125 PRs (#4434→#4239), every single-OS-failed CI run
since 2026-11-19 and the main-branch push runs for `mvn -B -T1C clean
verify` failures (one build OS red and the other green on the same
commit = flake suspect). Four test classes still fail on current main:
three fail on windows-latest only, and the fourth sits at its deadline
on both OSes. All fixes are test-side only (no `src/main` changes).

## Fixes and evidence

| Test class | Victims | Signature | Fix |
|---|---|---|---|
| `HarnessAgentStructuredOutputStreamEventsTest` | #4296, #4349, #4071,
main run 44879286932 (2026-11-20 to 11-23), all windows-latest |
`streamEvents(...).block(10s)` timed out at 10.2-11.3s per call; the
class takes 3.7-9.6s on windows-latest when green and 1-1.5s on ubuntu |
ephemeral `InMemoryThreadJournalStore` in the three workspace-backed
tests (the fourth already used one) |
| `HarnessAgentOverflowRecoveryTest` | #4042, #4426 (2026-11-26), both
windows-latest; the journal rows were added by #4399 on 11-25 | row
`[3]` (journal=true) crossed `block(30s)` at 36.3-38.1s and row `[4]`
passed with 33.8s; the same rows take 0.4-1.3s on ubuntu, and main's own
run 45595615922 needed 61s for the class on windows-latest | ephemeral
`InMemoryThreadJournalStore` in `newAgent` |
| `DashScopeMultiModalEmbeddingTest` | #4413 (2026-11-25),
windows-latest | the first SDK request in the fork hit the 5s latch
(7.29s elapsed); the class takes 1.4-4.2s on windows-latest even when
green | first-request latch 5s→15s |
| `AnthropicAutoConfigurationTest` | #2363, run 45137197507
(2026-11-23), windows-latest | the first gateway test crossed
`block(10s)` at 15.66s; the other three take under 1s, and this one
already takes 5-11s on windows-latest and 9-12s on ubuntu when green |
block 10s→30s |

The first two share one cause: since #4154 the default workspace journal
is `SqliteJournalStorage` on Windows, which opens a JDBC connection per
storage operation and commits every CAS as a durable transaction (DELETE
journal, synchronous EXTRA). A journaled turn issues about 20 such
writes at roughly 8ms each on a fast local disk. Neither class asserts
journal persistence, so they now use the ephemeral backend the
repository already documents for tests. Locally on Windows the
overflow-recovery class dropped from 17.9s to 5.6s and the
structured-output class from 3.2s to 1.6s.

## Constraint compliance

- Happy path zero cost: the journal swap removes work, the two
relaxations only move failure deadlines, and no sleeps or weakened
assertions were added.
- Structural hardening first: the journal swap is structural. For the
two cold-start waits the structural alternative, a warm-up request
before the timed section, would add a request to every run, so the
deadline was relaxed instead.
- Minimal widening anchored to measured data: each relaxation is 3x the
deadline that was crossed, and every comment cites its victims and
measured values.
- No `src/main` changes.

## Observed but deliberately not fixed here

-
`WorkerRuntimeTest.saturatedStartsDoNotBlockRecoveryAndDrainPreservesActiveLeases`
(#4294, windows-latest, 36.19s at the `renewed` latch): with the test's
4s worker lease a heartbeat delayed by more than 2.7s finds the lease
already expired and fails with `Worker lease lost` instead of arriving
late, so widening the latch (as #4274 did to 30s) cannot help. That
latch is the only place asserting the runtime renews leases, and a
longer lease would delay the first heartbeat by lease/3, so the fix
needs a design decision.
-
`SubagentFactoryDeclarationTest.declaredFactory_persistSessionIsolatesUsers`
(main run 45172445003, 2026-11-23, 31.45s) and
`ChatControllerTest.httpUsesExplicitCreationAndTargetedIdempotentControls`
(main run 44566773929 and #4255, both 2026-11-19): no recurrence since.
- Two windows-latest hangs that ended at the 2h job timeout:
`AgentSpawnToolPermissionTest` (#4305, run 44760439728) and
`AgentSpawnToolPlanModeTest` (main run 45739005058 on the current head).
Both classes wait with unbounded `.block()`; the root cause is not
established, and the 30-minute Surefire fork timeout in the root pom did
not end either run.
- The cost of the Windows default journal itself (one JDBC connection
and one durable transaction per storage operation) is a production
concern that deserves its own `src/main` change.
- Already fixed upstream, victims predate the fix:
`JevEvidenceProcessorTest` (13 runs, fixed by #4346),
`ChatSessionsTest`, `RocketMqExecutionTest` and `AgentScopeAdapterTest`
(fixed by #4274).
xzxiaoshan added a commit to xzxiaoshan/agentscope-java that referenced this pull request Dec 2, 2026
Merge main (9cfeaad, 31 commits) into the final-answer-gate branch and
resolve:

- MiddlewareBase (4 content conflicts): main's agentscope-ai#4399 adds the ON_AGENT_EVENT
  point and its onAgentEvent hook; this branch adds ON_FINAL_ANSWER and
  onFinalAnswer. Keep both. The enum keeps main's relative order with this
  branch's constant placed after ON_AGENT_EVENT, and the class javadoc lists
  both hooks, combining main's "notification hooks default to a no-op" with
  this branch's onAgentFinish and onFinalAnswer defaults.
- ReActAgent.ToolResultCallback (2 content conflicts): main passes the
  batch's resultHolder so a resolved result reaches middleware before its
  events; this branch passes withholdCandidateContent, which withholds the
  content events of a returnDirect-bound batch while a gate is active. The
  constructor takes both: onResult publishes the result fact and keeps
  withholding the content events.
- docs/dev middleware.md, EN and ZH (10 content conflicts each): combine
  main's onAgentEvent rows, notification ordering and recordEvent diagram
  lines with this branch's onFinalAnswer rows, gate ordering and lifecycle
  diagrams. Both sides had rewritten the stale "default is active
  everywhere" activePoints() wording; take main's. The hook counts read 9.
- onAgentEvent under a gate (auto-merged, no code change): the observer loop
  runs inside recordEvent, downstream of the gate's public-stream guard, so
  withheld live text and thinking never reach observers, while the certified
  projection does. Established by reading the merged code, not by a test.

Verified: mvn -B -T1C clean verify over the whole reactor (114 modules,
BUILD SUCCESS), run with -Dmaven.test.failure.ignore=true so that a failing
module does not skip its downstream modules: spotless:check on all 114
modules, 14092 tests, 28 failing testcases in 7 modules, none in a module
this branch touches. Re-running those 11 test classes in isolation yields
the same 24 failing testcases on this tree and on pure main (9cfeaad,
exported with git archive): the durable adapter module
(AgentScopeAdapterTest 2, ModelWorkerTest 2, ProcessRecoveryTest 2), the
durable sandbox extension (13), the sandbox examples (SandboxRoundTripTest
3, ToolInSandboxExampleTest 1) and RocketMqExecutionTest (1). The remaining
4 (GitLabOutboundClientTest 1, LocalSandboxClientTest 2,
CommandExecutorTest 1) pass in isolation on both trees and failed only
under full-reactor load. Core (3660) and harness (2330) suites: 0 failures,
0 errors, including ReActAgentFinalAnswerGateTest (58) and
ReActAgentFinalAnswerGateHandoffTest (5). docs npm test 20/20 and build
validation pass; mint broken-links still reports every internal link as
broken on this machine (2754), and the merged docs add no site links over
main.

Apart from the resolutions above, the merged tree differs from main by this
branch's pre-merge delta: the same 15 files. The 11 files main did not touch
are byte-identical to the pre-merge branch, and ReActAgent carries the same
changed lines except the constructor.
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