🤖 fix: present sub-projects to the agent as regular projects#3244
🤖 fix: present sub-projects to the agent as regular projects#3244ammar-agent wants to merge 1 commit into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
@codex review |
This comment has been minimized.
This comment has been minimized.
|
@codex review Both P2s addressed in 2aadcf0:
|
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
2aadcf0 to
6150fe5
Compare
|
@codex review Force-pushed a complete pivot. The previous direction (which you approved on the prior commit) made sub-projects a recognized branch with explicit "the X sub-project of Y at Z" framing and AGENTS.md tagging — the user rejected that direction in favor of having the agent see sub-projects as regular projects. This revision:
Please flag anything that looks wrong with the new direction, especially around the AGENTS.md inheritance change. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
6150fe5 to
f0de68e
Compare
|
@codex review Force-pushed an extension of the previous direction. The user wants sub-projects to look like regular projects to the agent (no "sub-project of …" framing, no relative-paths nudge in , no special bash tool description) but still wants parent AGENTS.md concatenated with the sub-project's so the agent inherits parent conventions transparently. This revision keeps everything from the previous round (env block + bash desc neutral, all
Behavior delta the user should know: sub-project workspaces now actually inherit parent AGENTS.md (the previous doubled-path lookup never found it), so anyone whose parent AGENTS.md previously had no effect on sub-project workspaces will start seeing it influence agent behavior. Please flag anything that looks wrong. |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
f0de68e to
a62901b
Compare
|
@codex review Force-pushed an extension of the previous round. The user asked: "Is it clear to the agent that the parent AGENTS.md came from the parent? E.g. a This revision adds a small markdown-invisible HTML-comment hint before each AGENTS.md segment naming its source path relative to the cwd:
HTML comments survive markdown rendering as no-ops but are visible to the model in the raw system prompt. We deliberately avoided the rejected v1 8 test cases cover: concatenation order, comment presence and ordering, depth computation across nesting levels, only-parent / only-sub fallbacks, regular-project no-op preservation, and stale-metadata degradation. Please flag anything that looks wrong with the comment-based hint approach. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a62901b91b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a62901b to
b1e5205
Compare
|
@codex review Force-pushed to address the previous round's P2 finding (good catch — scoped tool/model bodies lost the path-source marker because the top-level HTML comment didn't travel into the extracted section body). Two changes this round:
The H1 is deliberately just a path note ( 9 sub-project test cases now cover: byte-equal Please flag anything that still looks wrong. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1e5205988
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b1e5205 to
a6424bf
Compare
|
@codex review Force-pushed to address the previous round's P2 finding (great catch — the singular Two changes this round:
Also added 4 unit tests in This is a small behavior change for the rare case where a single AGENTS.md has multiple matching |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6424bf1fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a6424bf to
e2bade5
Compare
|
@codex review Force-pushed to address the previous round's P2 finding (sharp catch — the regex-based injection didn't respect fenced code blocks, so Two changes this round:
Total now: 11 sub-project test cases + 4 new |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2bade5b4c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e2bade5 to
f48fae8
Compare
|
@codex review Force-pushed to address the previous round's P2 finding (very nice catch — CommonMark §4.5 says a closing fence cannot have an info string, so Two changes this round:
Total now: 12 sub-project test cases + 4 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f48fae86fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Force-pushed to address the previous round's P3 finding (good catch — CommonMark §4.2 lets ATX headings start with up to 3 leading spaces, and markdown-it parses those as headings, but my regex was anchored at column 0). Two changes this round:
Total now: 13 sub-project test cases + 4 |
f48fae8 to
f6c73fe
Compare
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
f6c73fe to
3aadf83
Compare
Sub-project workspaces now look indistinguishable from a regular
single-project workspace rooted at the sub-project directory:
- The <environment> block uses the same per-runtime description and
guardrails it would use for any project at that cwd. No "the X
sub-project of the Y at Z" framing, no relative-paths preamble.
- Bash tool description is unchanged from the regular single-project
case (same "Runs in <cwd> - no cd needed" form).
- AGENTS.md is concatenated parent → sub-project (parent first so
general rules anchor before specific overrides). Each segment is
wrapped with two complementary path markers:
* A visible H1 heading naming the source path relative to the cwd
(e.g. `` # `../../AGENTS.md` ``). The heading both names the
segment's source AND bounds any scoped `## Tool:` / `## Model:`
sections inside the segment so they can't span across the
segment join into the next segment's narrative.
* A markdown-invisible HTML comment with the same path injected
after every ATX-style `## Tool:` / `## Model:` heading inside
the segment. The H1 doesn't survive scoped extraction, so the
inner comment carries the path provenance into per-tool/per-
model contexts. Heading-line scanning is fence-aware: scoped-
looking lines that sit inside a fenced code block (e.g. a
`markdown` documentation example showing how to structure
scoped sections) do NOT receive an injected comment, mirroring
the downstream markdown parser's fenced-content semantics.
- The parent root is derived by stripping the recorded sub-project
relative segment off the cwd, so worktree/SSH/Docker workspaces
read the parent's AGENTS.md from their own branch's checkout (not
from the user's local checkout, which may be on a different commit).
Depth of the relative-path heading tracks the actual sub-project
nesting depth.
- Stale-metadata fallback: if the recorded subProjectPath isn't a
descendant of projectPath, or the cwd doesn't end with the expected
suffix, we degrade to reading just the cwd's AGENTS.md verbatim
with no path-source heading or comment — historical behavior,
unchanged.
- Regular non-sub-project workspaces are unaffected: no path-source
markers are emitted (one source = no ambiguity), preserving the
exact prompt bytes for single-project workspaces.
Also align extractModelSection's multi-match semantics with
extractToolSection: collect every matching `## Model: …` section in
source order and concatenate, instead of returning only the first
match. Without this, sub-project model overrides were silently
dropped when the parent AGENTS.md also defined a matching `## Model:`
section — only the parent's body landed in the per-model section,
and the sub-project's intended override never reached the agent.
The change is principled (parallel to how tool overrides already
compose for multi-project workspaces) and removes the now-unused
internal extractSectionByHeading helper.
Replaces the earlier doubled-path lookup in
readSingleProjectContextInstructions (which always read the
sub-project's AGENTS.md as if it were the parent's, and tried to read
the sub-project's AGENTS.md from <cwd>/<rel>/<rel> which never
existed) with an inline helper that derives both the parent root and
the relative-path hint deterministically.
3aadf83 to
e570d57
Compare
|
@codex review Rebased onto latest |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Present sub-project workspaces to the agent exactly like regular single-project workspaces rooted at the execution cwd, while still inheriting parent
AGENTS.mdguidance. The parent and sub-project instruction segments are concatenated parent → sub-project with lightweight path-source markers (for example# `../../AGENTS.md`and# `./AGENTS.md`) so relative paths inside each segment stay anchored to the directory where that guidance was authored.Background
The original path-confusion bug came from sub-project agents preferring absolute paths and seeing too much parent-repo framing. A rejected first pass made the prompt explicitly describe “the sub-project of …”; the desired behavior is the opposite: the agent should see a normal project at its cwd. The only parent context it should receive is inherited
AGENTS.mdcontent, with enough source-path provenance to interpret any relative-path guidance correctly.Implementation
<environment>and tool descriptions neutral for sub-project workspaces; nosub-projectcallout and no relative-path nudge.InstructionSetscopes added onmain.InstructionSet.combinedContentfor sub-project context: visible H1 path headings bound scoped sections, while injected<!-- path -->comments inside## Tool:/## Model:sections preserve provenance after scoped extraction. The structuredfiles[]payload stays as authored for the Instructions tab.extractModelSectionwithextractToolSectionby collecting every matching## Model:section in source order, allowing later sub-project model guidance to layer after parent guidance.origin/main, resolving the conflict with the new structured instruction-loading / Instructions-tab work.Validation
bun test src/node/utils/main/markdown.test.ts src/node/services/systemMessage.test.tsbun test src/node/services/streamContextBuilder.test.ts src/node/services/aiService.test.ts src/node/runtime/runtimeHelpers.test.ts src/node/services/tools/bash.test.tsmake static-checkRisks
AGENTS.md; users whose parent guidance previously had no effect in sub-project workspaces will see it apply.extractModelSectionnow has multi-match semantics. This should match existing tool-section behavior, but it can affect AGENTS files with multiple matching model sections.Pains
InstructionSetcontent without leaking prompt-only markers into the panel's file display.Generated with
mux• Model:openai:gpt-5.5• Thinking:xhigh• Cost:$44.21