RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/AGENTS.md/anomalyco/opencode

AGENTS.md

packages/opencode/src/session/llm/AGENTS.md
AGENTS.md

Quality

61/100

Scores the file, not the repository.

Length

571 words

3 headings · 2 code blocks

Repository

193k

— · pushed 0 days ago

Last changed

3 days ago

First indexed 3 days ago.
anomalyco/opencode/packages/opencode/src/session/llm/AGENTS.mdRawGitHub
1# Session LLM Runtime Boundaries
2 
3`../llm.ts` is the opencode session LLM service. It owns opencode concerns: auth, config, model/provider resolution, plugins, permissions, telemetry headers, and runtime selection. It is the only file in this area that should know about the full session request shape.
4 
5This folder contains adapters behind that service boundary:
6 
7- `ai-sdk.ts` converts AI SDK `fullStream` parts into `@opencode-ai/llm` `LLMEvent`s. This is the default runtime path.
8- `native-request.ts` converts opencode's normalized session input into a native `@opencode-ai/llm` `LLMRequest`. It does not execute requests.
9- `native-runtime.ts` is the opt-in native runtime adapter. It decides whether a selected model is supported, builds the native request, bridges opencode tools into native executable tools, and delegates transport to `LLMClient` / `RequestExecutor`.
10 
11## File Structure
12 
13```txt
14src/session/
15 llm.ts session-owned orchestration and runtime selection
16 llm/
17 AGENTS.md boundary notes for the adapter layer
18 ai-sdk.ts AI SDK fullStream -> @opencode-ai/llm LLMEvent adapter
19 native-request.ts opencode/AI SDK-shaped input -> @opencode-ai/llm LLMRequest
20 native-runtime.ts native runtime gate, tool bridge, and LLMClient handoff
21```
22 
23Integration points:
24 
25- `../llm.ts` imports `LLMClient` from `@opencode-ai/llm/route`; native execution is the only path that calls it directly.
26- `../llm.ts` imports `LLMAISDK` from `./llm/ai-sdk`; the AI SDK path still calls `streamText(...)` locally, then adapts `result.fullStream` into shared `LLMEvent`s.
27- `../llm.ts` imports `LLMNativeRuntime` from `./llm/native-runtime`; this is the runtime-selection seam. Unsupported native requests return a reason and fall back to AI SDK.
28- `native-runtime.ts` imports `LLMNative` from `./native-request`; this keeps request lowering separate from transport and tool execution.
29- `native-request.ts` is the only adapter file that should construct `LLM.request(...)`, `LLM.model(...)`, `Message.*`, `SystemPart`, `ToolCallPart`, `ToolResultPart`, or `ToolDefinition` values from `@opencode-ai/llm`.
30- `ai-sdk.ts` and `native-runtime.ts` both emit `@opencode-ai/llm` `LLMEvent`s so downstream session processing does not care which runtime handled the request.
31 
32Keep new integration code on one of these seams. Avoid importing session services into `native-request.ts`; pass normalized data through `RequestInput` instead.
33 
34## Runtime selection
35 
36Both runtimes converge on the same `LLMEvent` stream consumed by the session processor. The gate is per-request: a single session can route some calls through native and fall back for others.
37 
38```txt
39 ╭───────────────────╮
40╭───────────────────────────▶│ session processor │
41│ ╰─────────┬─────────╯
42│ │
43│ │
44│ │
45│ ▼
46│ ╭─────────────────────────╮
47│ │ LLM.Service (../llm.ts) │
48│ ╰────────────┬────────────╯
49│ │
50│ │
51│ │
52│ ▼
53│ ╭───────────╮
54│ ╭─╯ ╰─╮
55│ │ native gate │
56│ ╰─╮ ╭─╯
57│ ╰─────┬─────╯
58│ │
59│ ╭────── no ──────┴─────── yes ────────╮
60│ │ │
61│ ▼ ▼
62│ ╭───────────────────────────╮ ╭───────────────────╮
63│ │ AI SDK │ │ native-runtime.ts │
64│ │ streamText / generateText │ ╰────────┬──────────╯
65│ ╰─────────────┬─────────────╯ │
66│ │ │
67│ ╭───╯ │
68│ │ │
69│ ▼ ▼
70│ ╭───────────────────────╮ ╭────────────────────────────╮
71│ │ ai-sdk.ts │ │ native-request.ts │
72│ │ fullStream → LLMEvent │ │ session input → LLMRequest │
73│ ╰──────────┬────────────╯ ╰──────────────┬─────────────╯
74│ │ │
75│ │ ╭───╯
76│ │ │
77│ ▼ ▼
78│ ╭─────────────────╮ ╭─────────────────────────────╮
79╰───────┤ LLMEvent stream │◀────────────┤ LLMClient · RequestExecutor │
80 ╰─────────────────╯ ╰─────────────────────────────╯
81```
82 
83`native-runtime.ts` evaluates the gate and either bridges into `@opencode-ai/llm` or returns control so `llm.ts` can take the AI SDK path. Tool execution stays opencode-owned in both branches; only request lowering and transport differ.
84 
85Safety boundary:
86 
87- AI SDK remains the default.
88- `OPENCODE_EXPERIMENTAL_NATIVE_LLM=true` or the umbrella `OPENCODE_EXPERIMENTAL=true` opts in. Native is not a global replacement.
89- Native execution currently supports OpenAI, opencode-managed OpenAI-compatible, and Anthropic API-key paths backed by `@ai-sdk/openai`, `@ai-sdk/openai-compatible`, or `@ai-sdk/anthropic` catalog entries.
90- Unsupported providers, OpenAI OAuth, and missing API-key cases fall back to AI SDK.
91 

Sections

  • Session LLM Runtime Boundaries
  • File Structure
  • Runtime selection

What it covers

architecture

Stack — with the evidence

typescript

(1.00)

bun

(1.00)

turborepo

(1.00)

node

(0.70)

react

(0.70)

solid

(0.70)

drizzle

(0.70)

postgres

(0.70)

tailwind

(0.70)

vite

(0.70)

playwright

(0.70)

cloudflare

(0.70)

aws

(0.70)

javascript

(0.60)

monorepo

(0.60)

github-actions

(0.60)

Format

AGENTS.md

A plain-markdown README for coding agents, deliberately unopinionated: no frontmatter, no globs, no vendor keys. That minimalism is why it became the one file a dozen different agents will read, and why it carries the least per-file targeting power of any format here.

What the corpus says about it

Repository

Owner
anomalyco
Language
—
License
—
Archived
no

All configs in this repo

Also in anomalyco/opencode

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
anomalyco/opencodepackages/core/src/tool/AGENTS.md · 193kAGENTS.mdtypescriptbun+14stylesecurity58/1003 days ago
anomalyco/opencodepackages/opencode/test/server/AGENTS.md · 193kAGENTS.mdtypescriptbun+14teststyleapi38/1003 days ago
anomalyco/opencodepackages/schema/AGENTS.md · 193kAGENTS.mdtypescriptbun+14styletypesdatabaseapi+165/1003 days ago
anomalyco/opencodepackages/opencode/AGENTS.md · 193kAGENTS.mdtypescriptbun+15styledatabaseapido-not81/1003 days ago
anomalyco/opencodeAGENTS.md · 193kAGENTS.mdtypescriptbun+14testlint-formatstyletypes+380/1003 days ago
anomalyco/opencodepackages/app/AGENTS.md · 193kAGENTS.mdtypescriptbun+14style56/100today
anomalyco/opencodepackages/app/e2e/performance/AGENTS.md · 193kAGENTS.mdtypescriptbun+14no sections16/1003 days ago
anomalyco/opencodepackages/codemode/AGENTS.md · 193kAGENTS.mdtypescriptbun+14api43/1003 days ago
anomalyco/opencodepackages/desktop/AGENTS.md · 193kAGENTS.mdtypescriptbun+14no sections30/100today
anomalyco/opencodepackages/effect-drizzle-sqlite/AGENTS.md · 193kAGENTS.mdtypescriptbun+14database38/1003 days ago
anomalyco/opencodepackages/llm/AGENTS.md · 193kAGENTS.mdtypescriptbun+14stylearchtesting-strategygit+157/1003 days ago
anomalyco/opencodepackages/opencode/src/server/routes/instance/httpapi/AGENTS.md · 193kAGENTS.mdtypescriptbun+14styleapi40/1003 days ago
anomalyco/opencodepackages/opencode/test/AGENTS.md · 193kAGENTS.mdtypescriptbun+14teststylearchtesting-strategy+181/1003 days ago
anomalyco/opencodepackages/session-ui/AGENTS.md · 193kAGENTS.mdtypescriptbun+14no sections30/100today
anomalyco/opencodepackages/ui/AGENTS.md · 193kAGENTS.mdtypescriptbun+14no sections30/100today
Diff against packages/core/src/tool/AGENTS.md Diff against packages/opencode/test/server/AGENTS.md Diff against packages/schema/AGENTS.md Diff against packages/opencode/AGENTS.md Diff against AGENTS.md Diff against packages/app/AGENTS.md Diff against packages/app/e2e/performance/AGENTS.md Diff against packages/codemode/AGENTS.md Diff against packages/desktop/AGENTS.md Diff against packages/effect-drizzle-sqlite/AGENTS.md Diff against packages/llm/AGENTS.md Diff against packages/opencode/src/server/routes/instance/httpapi/AGENTS.md Diff against packages/opencode/test/AGENTS.md Diff against packages/session-ui/AGENTS.md Diff against packages/ui/AGENTS.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
trick77/agents-md-syncAGENTS.md · 2AGENTS.mdtypescriptnode+4setupbuildteststyle+5100/1003 days ago
duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70AGENTS.mdtypescriptjavascript+5buildteststylearch+3100/1003 days ago
mui/material-uiAGENTS.md · 99kAGENTS.mdtypescriptjavascript+13setupbuildtestlint-format+9100/1003 days ago
n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199kAGENTS.mdtypescriptlangchain+16buildteststylearch+3100/1003 days ago
aaif-goose/gooseAGENTS.md · 52kAGENTS.mdrusttypescript+2setupbuildtestlint-format+6100/1003 days ago
TryGhost/Ghoste2e/AGENTS.md · 55kAGENTS.mdtypescriptjavascript+12setupteststylearch+2100/1003 days ago
code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67kAGENTS.mdtypescriptbun+10setupbuildtestlint-format+6100/1002 days ago
elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78kAGENTS.mdjavanode+4buildtestlint-formatstyle+2100/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack