Skip to content

feat: report agent definition files in the chat context behind fork-agent-definitions - #83

Merged
ibetitsmike merged 6 commits into
mainfrom
mike/custom-agent-types-context-subagent
Nov 10, 2026
Merged

ibetitsmike merged 6 commits into
mainfrom
mike/custom-agent-types-context-subagent

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #7

The agent already pins one subagent context resource per agent definition file it finds in the workspace, with its status and parse warnings, and spawn_agent reads them as custom agent types. The chat context API dropped them: contextResourceKind in coderd/x/chatd/context_prompt.go treated subagent as a reserved kind. The agent definitions UI (#75) needs them to show broken or warned definitions in the context popup.

Change

  • codersdk.ChatContextResourceKindSubagent ("subagent"), plus subagent_name and subagent_description on ChatContextResource, filled for OK rows.

  • pinnedContextResources reports subagent rows. OK rows keep the agent's parse warnings in error, which the field's doc already allows for OK rows. Non-OK rows (invalid, oversize, unreadable) go through the existing non-OK path with their status and error. An OK row without a name is skipped, like an OK skill without one.

  • Server.ContextResources drops subagent rows when fork-agent-definitions is off, like ACP harnesses behind chat-acp-subagents.

  • ContextUsageIndicator gets a label for the new kind, because RESOURCE_KIND_LABELS is a Record<ChatContextResourceKind, string>. Rendering subagent rows in the popup is left to the UI workstream (pstack W10: agent definitions UI #75): until then a non-OK subagent row only turns the indicator's warning tone on, and only with the experiment on.

  • .github/fork/check-apidoc.sh now sorts codersdk.ChatContextResourceKind too, as it already sorts codersdk.Experiment. The new constant lives in codersdk/fork_agent_definitions.go, so the enum spans two files, and swag emits its values in map order (the first CI run generated subagent last).

The prompt is unchanged: contextResourcesToPrompt still ignores subagent rows.

Tests

  • TestForkAgentDefinitionContextResources: with the experiment on, an OK definition reports name, description, size and its warning, an invalid one reports its status and error, and an unnamed OK one is skipped. With the experiment off only the instruction file is reported.
  • Negative controls, each turning the test red: the kind mapping removed, the experiment filter removed, the warning not copied, and the unnamed-row skip removed.
  • Ran in Colima: TestForkAgentDefinitionContextResources, TestPinnedContextResources, TestContextResources, TestContextResourcesToPrompt, the other TestForkAgentDefinition* tests, TestSDKFieldsFormatted, TestSwaggerParametersValid, site tsc --noEmit, and golangci-lint (no findings in the changed files). check-apidoc.sh passes twice in a row, and it still fails when two ChatContextResourceKind varnames are swapped in the committed swagger.json.

…gent-definitions

The agent already pins one subagent context resource per agent definition
file, but the chat context dropped them. Report them with their name,
description and parse warnings so the context popup can show broken or
warned definitions.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T00:58:41.361345Z fe6ee78 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 74ea92f790

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25d2367c49

ℹ️ 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".

…tom-agent-types-context-subagent

# Conflicts:
#	coderd/x/chatd/fork_agent_definitions_internal_test.go
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: fe6ee7851a

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this on behalf of @ibetitsmike.

Closing and reopening only to make GitHub recompute the merge ref against current main (c43627ac25) and run fork-ci on it. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this again on behalf of @ibetitsmike.

The merge ref now points at current main (c43627ac25), but the run started by the first reopen was queued against the old merge ref. This second reopen starts fork-ci on the recomputed merge. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike
ibetitsmike merged commit cfe57a9 into main Nov 10, 2026
20 of 27 checks passed
@ibetitsmike
ibetitsmike deleted the mike/custom-agent-types-context-subagent branch November 10, 2026 03:07
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head fe6ee7851a31f8e2ec07f77e16e3532f9bbf8b49:

  • fork-ci pull_request run 42745110001 passed; its build job checked out Merge fe6ee7851a into c43627ac25 (current main). All checks green. Run 42732035333 had also passed on this head.
  • Codex on this exact head: no major issues. The round 2 P2 (popover rendering) was dropped as W10/pstack W10: agent definitions UI #75 scope, replied to and resolved; 0 unresolved review threads. Merge state CLEAN.
  • The merge of main 873db0e resolved one conflict in a test file (it keeps both TestForkAgentDefinitionContextResources and TestForkAgentDefinitionToolResultType). No product code or generated files changed after 25d2367, and TestForkAgentDefinition*, TestPinnedContextResources and TestContextResources pass on this head.
  • UAT PASS at 25d2367: with the experiment on, GET /api/v2/chats/{id} .context.resources returned AGENTS.md as an ok instruction file, broken.md as an invalid subagent ("frontmatter: name is required"), huge.md as an oversize subagent, and reviewer.md as an ok subagent with its name, description and parse warning. Later prompts carry no subagent sources or bodies, and spawn_agent still lists reviewer. With the experiment off, only AGENTS.md is returned (upstream behavior). No server errors beyond the NATS cluster-host notice.

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.

1 participant