feat(agent): add run context#2950
Conversation
|
@get6 is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR adds a machine-readable “agent run context” that is persisted at task enqueue time, returned by the claim endpoint, and injected into the daemon execution environment (env vars + .multica/run/context.json). It also introduces a CLI command to inspect the current run context during agent execution.
Changes:
- Persist an issue snapshot (
issue/parent/properties) intoagent_task_queue.contextwhen enqueueing issue/mention tasks, and surface it through the claim response. - Add
internal/runcontextshared model + parsing/normalization helpers for snapshots and the final run-context file payload. - Write
.multica/run/context.jsonand exportMULTICA_RUN_CONTEXT+MULTICA_TASK_*/MULTICA_ISSUE_*env vars; addmultica issue context --output jsonand regression tests.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/pkg/db/queries/agent.sql | Adds context to the CreateAgentTask insert so snapshots can be stored on enqueue. |
| server/pkg/db/generated/agent.sql.go | Regenerates sqlc code to accept/pass the new context parameter. |
| server/internal/service/task.go | Builds and stores an issue snapshot JSON blob when enqueueing issue/mention tasks. |
| server/internal/runcontext/runcontext.go | New shared run-context model + helpers (identifier formatting, properties normalization, snapshot parsing). |
| server/internal/handler/daemon.go | Parses stored snapshots into claim responses; falls back when missing/orphaned. |
| server/internal/handler/daemon_test.go | Adds coverage ensuring stored snapshots round-trip via the claim endpoint. |
| server/internal/handler/agent.go | Extends AgentTaskResponse to include issue/parent/properties. |
| server/internal/daemon/types.go | Extends daemon task payload shape to carry run-context fields. |
| server/internal/daemon/execenv/runtime_config.go | Documents the new multica issue context command and run-context env/file injection in the meta-skill brief. |
| server/internal/daemon/execenv/execenv.go | Tracks RunContextPath on prepared environments and passes snapshot fields into context-file writing. |
| server/internal/daemon/execenv/execenv_test.go | Adds run-context file assertions and updates workdir entry expectations. |
| server/internal/daemon/execenv/context.go | Writes .multica/run/context.json during context file generation and references it in issue_context.md. |
| server/internal/daemon/daemon.go | Injects run-context env vars and wires run-context fields into the execenv task context. |
| server/internal/daemon/daemon_test.go | Adds unit coverage for env var injection behavior. |
| server/cmd/multica/help.go | Documents MULTICA_RUN_CONTEXT in CLI help text. |
| server/cmd/multica/cmd_issue_context.go | Adds multica issue context --output json to print the current run-context JSON file. |
| server/cmd/multica/cmd_issue_context_test.go | Tests CLI behavior for valid context, missing env, and missing file/orphaned runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // CR/LF and other whitespace control bytes collapse to a single space; other | ||
| // C0 controls and DEL are dropped; markdown structural characters that have | ||
| // meaning in inline context (`*`, `_`, `` ` ``, `\`, `[`, `]`, `<`) are | ||
| // meaning in inline context (`*`, `_`, “ ` “, `\`, `[`, `]`, `<`) are |
There was a problem hiding this comment.
Fixed in ba45b5b: replaced the smart quotes with a literal backtick in the documented escaping set.
0dccf46 to
d52acac
Compare
What does this PR do?
Adds a machine-readable agent run context so Multica agents can read first-class issue/task metadata before parsing prose descriptions or comments. The context is captured at dispatch time, exposed through environment variables, and written to
.multica/run/context.jsonfor runtime consumers.This approach keeps the P0 scope focused on run-time context injection and avoids introducing a broader issue-properties data model change in this PR.
Related Issue
Multica workspace issue: ITT-150
Type of Change
Changes Made
server/internal/daemon/execenv/: injectsMULTICA_RUN_CONTEXT,MULTICA_ISSUE_*, andMULTICA_TASK_*values into agent runtime environments.server/internal/daemon/: writes.multica/run/context.jsonand documents that the context is a dispatch-time snapshot.server/internal/runcontext/: adds a shared run context model withtask,issue,parent, andpropertiestop-level keys.server/cmd/multica/: addsmultica issue context --output jsonfor inspecting the current run context.server/internal/service/andserver/pkg/db/queries/: preserves issue task snapshots in queued task context so the daemon can build run context without schema changes.How to Test
MULTICA_RUN_CONTEXTplus the expectedMULTICA_ISSUE_*/MULTICA_TASK_*environment values.multica issue context --output jsonand confirm it returns the run context JSON.Checklist
apps/web/features/landing/i18n/) and relevant docs (apps/docs/content/docs/)apps/docs/content/docs/developers/conventions.zh.mdx(terminology, mixed-rule fortask/issue/skill)Notes on non-applicable checklist items: this PR does not change UI, runtime/coding-tool tabs, landing copy, docs content, or Chinese product copy.
Risk: this touches core agent task spawning and context propagation. The implementation intentionally reuses the existing queued task
contextsnapshot instead of adding schema/migration scope, but review should check compatibility with mention tasks, squad leader tasks, quick-create tasks, and future context extensions.AI Disclosure
AI tool used: Multica Agent / Codex, supervised by Hermes
Prompt / approach:
Implemented from Multica workspace issue ITT-150. Codex produced the initial implementation and tests; Hermes verified the diff, resolved the
origin/mainconflict aroundForceFreshSession, reran the focused backend tests, and opened this PR using the repository PR template.Screenshots (optional)
N/A — backend/CLI runtime context change only.