Skip to content

feat: discover nested AGENTS.md within trusted sources - #2110

Merged
JAORMX merged 3 commits into
mainfrom
spike/agents-hierarchy-20261005
Oct 7, 2026
Merged

JAORMX merged 3 commits into
mainfrom
spike/agents-hierarchy-20261005

Conversation

@JAORMX

@JAORMX JAORMX commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Relates to #2090. Implements lazy nested AGENTS.md guidance within selected, admitted instruction sources. Main's intentional removal of ADRs, acceptance plans, and process scaffolding is preserved; none are restored.

Current head: f46bd7742ddc2adf965d4b5aa158bbb15f8e7787. History is now three commits: the original 43 commits squashed into one, the review repairs, and the live-test extension. Rebased onto e731897077c75b020190f0d7b6e0b78af15082f1.

Behavior

  • Initially load the admitted starting path, then discover nested guidance after successful built-in Read/Edit/Write/Copy/Move/Remove operations for the next model request. No repository-wide scan or Shell/search/list/custom/MCP inference; discovery does not gate authorized effects or create read-ledger evidence.
  • Preserve per-directory AGENTS-first/CLAUDE fallback, root-to-leaf precedence, sibling applicability, whole-source selection, and trusted-source boundaries.
  • Retain loaded guidance across live-session messages, approvals, and compaction without live refresh or persisted instruction bodies. Restart/reattachment rediscovers. Settled sessions with no loaded guidance may release their attachment and discover newly created files on later turns.
  • Fresh children load current admitted guidance; conversation forks retain independent copies of previously loaded guidance. Child checkouts do not become instruction authority. Unmapped and no-filesystem placements retain their restrictions.
  • Operator-only harness_context.project_instruction_max_bytes defaults to 65,536 bytes and supports higher configured values. Content, metadata, discovery, and warnings are bounded. Failures and omissions produce safe advisories without changing tool permissions.

Review repairs

  • Enable nested discovery for ordinary default-source children when their workspace mapping is verified; retain the safe fallback for other placements.
  • Preserve inherited nested guidance in a conversation fork's first request.
  • Reserve complete instruction-file paths against the metadata allowance and traverse ancestors incrementally instead of constructing an unbounded list of prefixes.
  • Preserve successfully loaded guidance when another read fails, including configured-source wrappers and empty failed refreshes. Forward safe warnings without falling back to an unselected source.
  • Add regressions for configured errors, repeated failures, higher limits, child-budget independence, no-filesystem and different-workspace isolation, and first-request fork behavior.
  • Correct fresh-child versus fork documentation. No new source-replacement warnings or instruction-content analysis were added.

Live hierarchy coverage

Extended the existing writable-subagent live scenario in e2e/subagent_writable_test.go; no new scenario or workflow. The expected output appears only in nested AGENTS.md. The test checks the real child transcript for a successful input Read followed by a later Write, rejects manual instruction-file/search discovery, and verifies the exact output in the parent workspace.

The extended scenario passed with anthropic/claude-haiku-4.5 through OpenRouter. The archived live transcript shows the child reading nested-child-guidance/input.txt, then writing nested-child-guidance/output.txt with the nested-only marker. The e2e-live label remains enabled.

The test-only change passed go test -tags=e2e -run '^$' ./e2e/... and tagged lint for new code. Full tagged-package lint also reports three pre-existing unconvert findings in e2e/lease_exclusion_test.go; they were not altered.

Verification

Passed locally on repair commit a041bd2f8, before the live-test-only extension:

  • task lint
  • task test
  • task test:race
  • task docs
  • Offline mecademo: tool result, permission ask/approval, final result, and background result collection.

Full gates used an identical short-path checkout because existing embedded Unix-socket tests reject the long development-worktree path. Initial aggregate lint/race attempts hit their 600-second limits while competing for resources; final sequential runs with bounded Go parallelism passed. No assertions were disabled or lint thresholds relaxed.

Independent spec, standards, test-adequacy, security, architecture, and reuse reviews completed. Follow-up reviews confirmed the remaining error-retention and alternate-placement findings were resolved.

PANEL: ship_blockers=0 important=0 advisory=0 reviewer_failures=0

CI status

34 passed, 3 skipped, 2 failed; no pending checks. CI is not fully green. Regular Build, Lint, Test (race), Analysis, API compatibility, docs, standalone modules, MicroVM, and Kubernetes checks passed. Live Kubernetes/OpenRouter also passed.

  • Live e2e/OpenRouter: 34 of 35 specs passed, including the extended writable-subagent hierarchy test. The existing WebSearch/Exa-default spec failed. Both archived attempts show the model did invoke WebSearch; Exa returned its anonymous-tier rate-limit notice. That notice was presented as a normal result rather than the expected temporarily unavailable response, so the existing assertion failed. This is not missing model tool use or a nested-guidance failure. No unrelated WebSearch changes or blind paid reruns were made.
  • Execution-provider production qualification: the known TestKindExecutionProductionPendingDeleteOutageRecovery failure recurred (listed=0, exact_code=not_found). The exact base commit already fails identically. The qualification test and lifecycle-store source are unchanged by this PR; its root cause needs a separate execution-provider investigation.

No production deployment or PR merge performed.

Base automatically changed from plan/agents-instruction-hierarchy to main October 6, 2026 07:38
@JAORMX JAORMX changed the title Spike: best-effort AGENTS.md hierarchy Implementation: best-effort AGENTS.md hierarchy (WIP) Oct 6, 2026
@JAORMX JAORMX changed the title Implementation: best-effort AGENTS.md hierarchy (WIP) feat: discover nested AGENTS.md within trusted sources Oct 6, 2026
@JAORMX
JAORMX marked this pull request as ready for review October 6, 2026 14:49
JAORMX and others added 2 commits October 7, 2026 08:58
Retain scoped guidance for live sessions and inherit it in child forks, with configurable content and metadata budgets.

Co-authored-by: Mecatl <[email protected]>
Bound instruction discovery using the configured metadata allowance, preserve successful guidance alongside safe failure warnings, and retain mapped child and fork context. Add factory and isolation regressions and clarify instruction lifetime documentation.

Co-authored-by: Mecatl <[email protected]>
Reuse the existing live writable-child scenario and verify a nested-only instruction through the resulting file and ordered child tool transcript.

Co-authored-by: Mecatl <[email protected]>
@JAORMX JAORMX added the e2e-live Run the live e2e suite on this PR label Oct 7, 2026
@JAORMX
JAORMX merged commit 0c47287 into main Oct 7, 2026
38 of 42 checks passed
@JAORMX
JAORMX deleted the spike/agents-hierarchy-20261005 branch October 7, 2026 12:30
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 7, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-live Run the live e2e suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant