fix(goal): harden contextual tool and migration boundaries / Goal/context 工具与迁移边界完整修复 - #8007
Merged
SivanCola merged 3 commits intoAug 9, 2026
Conversation
Problem: Context-dependent tools could be called outside their owning Goal, Plan, Jobs, or child-agent context, and failed legacy AutoResearch migration lost its retry identity after restart. Root cause: Availability was enforced by scattered execution checks while provider-visible registration, host metadata, mixed batches, and inherited child context used different state. The Goal sidecar writer also fenced every new write without preserving a pending legacy task id. Fix: Add a shared ContextualTool execution contract with one-repair run-loop handling, isolate child Goal/Jobs/memory state, project contextual schemas only for host metadata, and retain pending legacy task ids until a Goal-only sidecar is durably committed. Verification: go test ./... -count=1 cd desktop && go test ./... -count=1 go test -race ./internal/control ./internal/agent ./internal/tool ./internal/tool/builtin ./internal/jobs ./internal/memory -count=1 go vet ./... golangci-lint run --timeout=5m scripts/cache-guard.sh git diff --check
Problem: The repository lint baseline rejected the intentional size and complexity increase from the contextual execution gate, mixed-batch repair handling, child context isolation, and retryable Goal migration state. Root cause: The new owner-level safeguards add measured branches and lines to existing shared files, so the current baseline was lower than the post-fix repository metrics. Fix: Update only the affected file budgets and the aggregate complexity budget; unrelated baseline drift is left unchanged. Verification: go run ./tools/repolint git diff --check
Problem: The pull request was based on an older main-v2 and became conflicting after session recovery changes landed. Root cause: The base evolved shared agent, controller, desktop, and lint-baseline files after this branch was created. Fix: Merge the latest main-v2 into the contextual-boundary fix, resolve the repolint baseline semantically, and retain both session recovery and Goal/context isolation changes. Verification: Repolint baseline was regenerated from the merged tree; focused and full checks will run against the pushed merge head.
esengine
added a commit
that referenced
this pull request
Aug 9, 2026
Baseline: main-v2 entries kept, this branch's three memory entries re-applied (store.go 83, store_v2 17/17), totals adjusted by those deltas on top of main-v2's #8007 baselined growth.
This was referenced Aug 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up hardening for #7959 after Goal/context-tool boundary review.
@bfxh identified the original issue.
Problem
Context-dependent tools could be called from stale transcripts or the wrong workflow phase. Mixed tool batches could repeat valid work after one unavailable contextual call, child agents could inherit parent Goal/Jobs/live-memory state, and failed legacy AutoResearch migration could lose its retry identity after restart.
Fix
ContextualToolcontract while keeping provider schemas static for cache stability.autoResearchTaskIDwithresearchMode=Onwhile legacy archives are blocked; validate and read archives without mutation, retry on restart or/goal resume, and clear compatibility fields only after the Goal-only sidecar is durably written.Compatibility
Existing sidecars with Goal text migrate without reading an archive. Sidecars awaiting archive migration remain fail-closed and retryable across restarts. New Goal-only writes use
budgetClassas the budget authority andresearchMode=Offas the downgrade fence, so older readers do not reactivate AutoResearch after a successful migration.Verification
go test ./... -count=1cd desktop && go test ./... -count=1go test -race ./internal/control ./internal/agent ./internal/tool ./internal/tool/builtin ./internal/jobs ./internal/memory -count=1go vet ./...golangci-lint run --timeout=5mgo run ./tools/repolintscripts/cache-guard.shscripts/check-cache-impact.shscripts/check-docs-impact.shgit diff --checkRepolint-baseline: updated only the aggregate complexity budget and the affected contextual-boundary files; unrelated baseline drift was left unchanged.
Documentation-impact: none - CHANGELOG.md is the release ledger; no docs/*.md contract changed.
Cache-impact: none - provider-visible tool schemas remain static; contextual projections are used only by host execution and metadata.
Cache-guard: go test -race ./internal/control ./internal/agent ./internal/tool ./internal/tool/builtin ./internal/jobs ./internal/memory; scripts/cache-guard.sh
System-prompt-review: reviewed against the cache-first contract; no system prompt bytes changed.