Skip to content

docs: plan workspace agent context#613

Draft
mariusvniekerk wants to merge 8 commits into
mainfrom
codex/workspace-agent-context-plan
Draft

docs: plan workspace agent context#613
mariusvniekerk wants to merge 8 commits into
mainfrom
codex/workspace-agent-context-plan

Conversation

@mariusvniekerk

Copy link
Copy Markdown
Collaborator

Workspace agents currently infer PR and issue context from branch names, paths, repo instructions, and UI state. That works surprisingly well for provider-backed items, but Kata task workspaces need an explicit source-aware context path because their task identity is not a provider issue or pull request number.

This draft captures the proposed generated-context design, including a canonical workspace context file, launch-scoped agent-specific files, and guardrails against overwriting repo-owned AGENTS.md or CLAUDE.md.

generated by a clanker

mariusvniekerk and others added 3 commits June 29, 2026 10:19
Workspace-launched agents currently infer source context from branch names, paths, repo instructions, and UI metadata rather than from a generated local instruction file. Kata-backed workspaces need a more explicit path because their task identity is not a provider issue or pull request number.

This plan records the current behavior and lays out a source-aware generated context design that can support PRs, provider issues, and Kata tasks without overwriting checked-in agent guidance.

Validation: rg placeholder scan for the new plan.

Generated with Codex
Co-authored-by: Codex <codex@openai.com>
Workspace agent launches currently rely on ambient worktree and repo context rather than generated local instruction files. That was easy to assume incorrectly while planning Kata task support, so the workspace context now records the current boundary and points to the follow-up plan.

Validation: scripts/context-sync --check; verified documented anchors with rg.

Generated with Codex
Co-authored-by: Codex <codex@openai.com>
Generating Claude-specific context only when the user launches Claude keeps workspace setup quiet and avoids creating files for unused agents. The plan now separates canonical workspace context from target-specific files and records the guardrail that repo-owned CLAUDE.md or AGENTS.md must never be overwritten.

Validation: rg placeholder scan for the updated plan.

Generated with Codex
Co-authored-by: Codex <codex@openai.com>
@roborev-ci

roborev-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown

roborev: Combined Review (8bebd53)

Medium-risk issue found in the implementation plan; security review found no additional issues.

Medium

  • docs/superpowers/plans/2026-06-29-workspace-agent-context-implementation.md:252
    The plan writes generated context files such as .middleman/agent-context.md, CLAUDE.md, and AGENTS.local.md inside the Git worktree without excluding them from Git status or workspace diffs. Existing dirty checks count untracked files, so prepared workspaces could appear dirty, pollute diffs, and block workflows requiring a clean worktree.
    Fix: Add implementation and tests to keep generated context files out of Git status/diff, for example by writing outside the worktree or adding exact generated paths to .git/info/exclude before writing. Include setup/launch tests asserting git status --porcelain remains clean.

Panel: ci_default_security | Synthesis: codex, 8s | Members: codex_default (codex/default, done, 1m59s), codex_security (codex/security, done, 12s) | Total: 2m19s

Agent context generation needs to reflect workspace state at the moment an agent is launched, not just the state from workspace setup. The plan now requires regenerating context on every launcher-menu agent start and includes the issue-backed workspace case where an associated PR appears later.

Validation: rg placeholder scan for the updated plan.

Generated with Codex
Co-authored-by: Codex <codex@openai.com>
@roborev-ci

roborev-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown

roborev: Combined Review (81e5f0a)

Summary verdict: two Medium findings need addressing; no High or Critical findings were reported.

Medium

  • docs/superpowers/plans/2026-06-29-workspace-agent-context-implementation.md:277

    • Problem: The plan writes generated context files into the checked-out worktree, but the dirty-worktree task never requires excluding or cleaning them. This could make workspaces show middleman-generated untracked files and risk accidental commits or diff pollution.
    • Fix: Add an implementation/test step to keep generated paths out of git status, such as updating the per-worktree git exclude for .middleman/agent-context.md and safe generated agent files, or storing the canonical context in a git-private path.
  • docs/superpowers/plans/2026-06-29-workspace-agent-context-implementation.md:142

    • Problem: The associated-PR test treats MRTitle on an issue workspace as the associated PR title, but existing workspace summaries use those fields for the owner item. For issue workspaces, the title is the issue title and associated PR metadata is not joined.
    • Fix: Either only render the associated PR number from AssociatedPRNumber, or add an explicit associated-PR lookup/model and tests that keep issue title data separate from linked PR data.

Panel: ci_default_security | Synthesis: codex, 12s | Members: codex_default (codex/default, done, 2m7s), codex_security (codex/security, done, 9s) | Total: 2m28s

Generated workspace guidance should orient the launched agent to the known source item without prescribing a provider-specific fetch workflow. The plan now makes that boundary explicit and adds an acceptance test for concise forge identity, URLs, and absence of CLI/API instructions.

Validation: rg placeholder scan for the updated plan.

Generated with Codex
Co-authored-by: Codex <codex@openai.com>
@roborev-ci

roborev-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown

roborev: Combined Review (5498679)

Documentation-only review combined: 2 Medium findings, no High or Critical findings.

Medium

  • docs/superpowers/plans/2026-06-29-workspace-agent-context-implementation.md:89
    The plan writes generated context files directly into the worktree but does not require excluding them from Git status/diff output or protecting an existing unmarked .middleman/agent-context.md. Implemented as written, setup/launch could make every workspace dirty and may overwrite repo/user-owned files.
    Fix: Add an explicit task to either store generated context outside the worktree or add local Git excludes and ownership-marker checks for every generated path, including .middleman/agent-context.md, with tests proving workspace diffs stay clean and unmarked files are preserved.

  • docs/superpowers/plans/2026-06-29-workspace-agent-context-implementation.md:26
    The plan says to build source-aware context from WorkspaceSummary, but the proposed context includes source URLs and the test snippets use issue-specific title fields that the current summary shape does not provide as such. This leaves no concrete data path for rendering provider issue/PR URLs and risks an implementation that silently omits the most useful source link.
    Fix: Add a task to fetch or expose generic source item fields such as title, state, and URL from the existing issue/MR rows, and update the planned tests to assert those fields are populated.


Panel: ci_default_security | Synthesis: codex, 9s | Members: codex_default (codex/default, done, 3m2s), codex_security (codex/security, done, 15s) | Total: 3m26s

mariusvniekerk and others added 2 commits June 29, 2026 13:47
Generated guidance files should never appear as untracked workspace noise or accidentally get committed with task work. The plan now requires middleman to verify generated context paths are ignored before writing them, append a narrow .gitignore block when needed, and avoid generated root instruction files that cannot be safely ignored.

Validation: rg placeholder scan for the updated plan.

Generated with Codex
Co-authored-by: Codex <codex@openai.com>
Root-level .local.md files may be created by users, hooks, or other tools before middleman launches an agent. The plan now treats any existing AGENTS.local.md or CLAUDE.local.md as user-owned for this purpose: skip the companion file entirely, keep refreshing only the canonical .middleman context, and avoid warnings or ignore-rule edits for files middleman did not create.

Validation: rg placeholder scan for the updated plan.

Generated with Codex
Co-authored-by: Codex <codex@openai.com>
@roborev-ci

roborev-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown

roborev: Combined Review (b78bd4f)

Documentation-only PR has medium-risk design issues to address before implementation.

Medium

  • docs/superpowers/plans/2026-06-29-workspace-agent-context-implementation.md:412
    The plan appends generated ignore rules to the worktree’s .gitignore, which can modify a tracked repo file or create an untracked .gitignore, polluting workspace diffs and risking accidental PR changes.
    Fix: Write these entries to a Git-local exclude file, such as the path from git rev-parse --git-path info/exclude, and add a test that context generation leaves git status --porcelain clean except for user edits.

  • docs/superpowers/plans/2026-06-29-workspace-agent-context-implementation.md:609
    Target-specific files are only written when absent and are never refreshed afterward, so a CLAUDE.local.md or AGENTS.local.md created by middleman on the first launch can become stale even though launch-time freshness is a stated requirement.
    Fix: Make companion files stable pointers to .middleman/agent-context.md, or safely distinguish and refresh middleman-owned files while still leaving user-owned files untouched; add a test for an existing generated local file after workspace metadata changes.


Panel: ci_default_security | Synthesis: codex, 9s | Members: codex_default (codex/default, done, 1m39s), codex_security (codex/security, done, 14s) | Total: 2m2s

@mariusvniekerk

Copy link
Copy Markdown
Collaborator Author

If we don't add the gitignore changes it will be WORSE

Workspace setup now writes an ignored canonical context file, and agent launches refresh it while preserving repo-owned and user-owned instruction files. The context model carries source item identity for PRs, provider issues, and Kata tasks without adding API surface.
@roborev-ci

roborev-ci Bot commented Jun 30, 2026

Copy link
Copy Markdown

roborev: Combined Review (40c0edc)

Review verdict: changes need follow-up before merge due to medium coverage and instruction-injection risks.

Medium

  • internal/server/huma_routes.go:6376
    The launch-time agent context behavior is only covered by a direct handler test, not an API/e2e test through ServeHTTP with the real route, SQLite row, and worktree side effects. This is a user-visible workspace runtime workflow, and repo guidance expects route-level coverage for API/data-flow changes.
    Fix: Add an API/e2e test for POST /api/v1/workspaces/{id}/runtime/sessions that launches an agent target and asserts stale canonical context is refreshed, the correct companion file is created/preserved, and generated paths are ignored.

  • internal/workspace/agent_context.go:116
    Kata metadata is written into agent context as raw Markdown list values. A task/project name, short ID, qualified ID, or UID containing embedded newlines can break out of the - Label: value line and inject apparent top-level instructions into .middleman/agent-context.md, which local agents are then pointed at via AGENTS.local.md/CLAUDE.local.md.
    Fix: Treat Kata/provider-derived strings as untrusted. Render them in a safer form such as blockquoted sections, or normalize scalar fields by removing/rejecting CR/LF and Markdown structure. Add tests with newline-bearing Kata metadata fields, not just hostile titles.


Panel: ci_default_security | Synthesis: codex, 9s | Members: codex_default (codex/default, done, 5m37s), codex_security (codex/security, done, 2m32s) | Total: 8m18s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant