Skip to content

Conversation

@betterclever
Copy link
Contributor

@betterclever betterclever commented Jan 29, 2026

ENG-100 — OpenCode Agent Component

Summary

  • Add OpenCode agent component to run a non-interactive investigation loop in Docker.
  • Generate opencode.json wired to the MCP gateway for tool calls.
  • Produce a markdown report output from the agent.
  • Stream terminal output for execution visibility.

What changed

  • New OpenCode agent component definition under worker/src/components/ai/opencode.ts.
  • Docker execution flow to set up workspace, write configs/prompts, and run OpenCode.
  • Gateway token resolution + MCP config injection for agent tool access.
  • Output wiring for report and logs.

How it works (high level)

  1. Create /workspace and context/task files.
  2. Build opencode.json with MCP gateway URL + token.
  3. Write investigator prompt template.
  4. Run OpenCode in non-interactive mode.
  5. Return markdown report + terminal stream.

Testing

  • Not run (please run relevant workflow / E2E manually).

Notes

  • PR base: ENG-132.
  • Stacked with ENG-101/102.

Refs: ENG-100

Adds the new OpenCode agent component with configurable 'providerConfig'. Refactors common gateway token logic into a shared 'utils.ts' used by both AI Agent and OpenCode.

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Copy link

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

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: a03de01336

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

Comment on lines +226 to +231
env: {
// OpenCode might need API keys.
// If the definition includes an API Key in the 'model' contract, we should pass it.
...(model?.apiKey
? { OPENAI_API_KEY: model.apiKey, ANTHROPIC_API_KEY: model.apiKey }
: {}),

Choose a reason for hiding this comment

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

P2 Badge Forward API keys for non-OpenAI providers

The component accepts the shared LLMProviderSchema, which includes gemini and openrouter providers, but the container environment only forwards OPENAI_API_KEY/ANTHROPIC_API_KEY. When a user selects gemini or openrouter and supplies an API key in the model input, no provider-specific key is passed into the OpenCode container, so authentication will fail unless they manually duplicate it via providerConfig. This makes those providers effectively unusable despite being allowed by the contract.

Useful? React with 👍 / 👎.

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