Skip to content

feat: ITT-150 add agent run context#2949

Closed
get6 wants to merge 3 commits into
multica-ai:mainfrom
get6:codex/itt-150-run-context
Closed

feat: ITT-150 add agent run context#2949
get6 wants to merge 3 commits into
multica-ai:mainfrom
get6:codex/itt-150-run-context

Conversation

@get6
Copy link
Copy Markdown

@get6 get6 commented May 20, 2026

Summary

  • Inject machine-readable agent run context env vars and .multica/run/context.json at task spawn time.
  • Add shared runcontext model and multica issue context --output json for current run context inspection.
  • Handle missing/orphaned run context explicitly and add regression coverage for daemon, handler, execenv, and CLI paths.

Closes ITT-150

Test

cd server
go test ./cmd/multica ./internal/daemon ./internal/daemon/execenv ./internal/handler ./internal/service

Copilot AI review requested due to automatic review settings May 20, 2026 12:47
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

@get6 is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

…text

# Conflicts:
#	server/internal/service/task.go
@get6
Copy link
Copy Markdown
Author

get6 commented May 20, 2026

Superseded by clean ITT-150 PR: #2950

@get6 get6 closed this May 20, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a shared “agent run context” concept that is captured at task enqueue time, persisted on the task row, and then injected into daemon-spawned agent runs as both environment variables and a machine-readable .multica/run/context.json file. It also introduces a CLI command to inspect that context and tightens CLI behavior in agent execution contexts (no fallback to member config/identity).

Changes:

  • Persist an issue snapshot JSON on agent_task_queue.context for issue-bound tasks and surface it through the daemon claim response.
  • Write .multica/run/context.json at execenv preparation time and inject MULTICA_RUN_CONTEXT + task/issue env vars for agent runs.
  • Add multica issue context --output json plus regression tests across daemon/handler/execenv/CLI paths.

Reviewed changes

Copilot reviewed 21 out of 22 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 CreateAgentTask insert to persist the issue snapshot at enqueue time.
server/pkg/db/generated/agent.sql.go Regenerates sqlc bindings to include the new Context parameter.
server/internal/service/task.go Builds and stores an IssueSnapshot JSON payload when enqueueing issue/mention tasks.
server/internal/runcontext/runcontext.go Introduces shared run-context models + helpers (normalize/parse/build).
server/internal/handler/daemon.go Reads stored snapshot from task context, falls back explicitly when missing/corrupt, and returns issue/parent/properties in claim response.
server/internal/handler/daemon_test.go Adds regression test ensuring snapshot round-trips through claim response.
server/internal/handler/agent.go Extends task API response shape to include issue, parent, and properties.
server/internal/daemon/types.go Extends daemon task model to carry run-context fields from the claim response.
server/internal/daemon/execenv/runtime_config.go Documents the new multica issue context --output json command and run-context env vars.
server/internal/daemon/execenv/execenv.go Tracks RunContextPath on the prepared environment for injection.
server/internal/daemon/execenv/execenv_test.go Verifies .multica/run/context.json is written and contains expected content.
server/internal/daemon/execenv/context.go Writes .multica/run/context.json alongside the existing issue context file.
server/internal/daemon/daemon.go Injects run-context env vars and includes run-context fields in execenv context creation.
server/internal/daemon/daemon_test.go Adds unit test coverage for run-context env var injection.
server/cmd/multica/help.go Documents MULTICA_RUN_CONTEXT in CLI help output.
server/cmd/multica/cmd_issue_test.go Adds tests for agent headers and multiline preservation while expanding issue command coverage.
server/cmd/multica/cmd_issue_context.go Adds multica issue context command to print current run context JSON.
server/cmd/multica/cmd_issue_context_test.go Adds coverage for successful printing and explicit missing/orphaned context errors.
server/cmd/multica/cmd_auth.go Avoids token fallback in agent execution context; enriches auth status output with token source + mutation identity.
server/cmd/multica/cmd_auth_test.go Adds tests for auth status output behavior in agent contexts.
server/cmd/multica/cmd_agent.go Introduces stricter agent-execution identity parsing/validation and requires MULTICA_TOKEN in agent context.
server/cmd/multica/cmd_agent_test.go Adds tests ensuring agent-context token behavior and identity guards are enforced.

💡 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
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.

2 participants