llama_shim
AGENTS.md0 starsChanged 7 months agoMITView on GitHub
This repository is an OpenAI-compatible shim. Any task that touches /v1/responses, /v1/conversations, /v1/chat/completions, OpenAPI, backlog status, or compatibility claims must be checked against current official OpenAI docs before it is marked done. Use this order every time: 1. Start with the local docs index at openapi/llms.txt. Use it as a map of relevant official pages only. It is not the source of truth for exact request or response contracts. https://developers.openai.com/api/docs/llms.txt chech update if needed. 2. Use OpenAI Docs MCP tools…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,266 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- openapi/llms.txtllms.txt
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
56 rules. About 0 are common, 40 are distinctive, and 16 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈40
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Use this order every time:
- Very specific: line 11
Start with the local docs index at openapi/llms.txt.
- Distinctive: line 12
Use it as a map of relevant official pages only.
- Very specific: line 15
Use OpenAI Docs MCP tools against developers.openai.com and platform.openai.com.
- Distinctive: line 16
Search first, then fetch the exact page or section you need.
- Distinctive: line 17
Do a final spot-check on the official site directly for the exact page or endpoint you are validating.
- Distinctive: line 18
Prefer only official OpenAI domains.
- Distinctive: line 19
If MCP and the official site disagree, or MCP is thin, ambiguous, or missing exact schema details, treat the current official site page as …
- Distinctive: line 31
Do not close a compatibility task from memory alone.
- Distinctive: line 57
Do not mark a task done if only the route exists but the documented semantics still differ.
- Distinctive: line 61
Use a real upstream fixture before closing parity work when any of the following is true:
- Very specific: line 78
Add or reuse a request template under internal/httpapi/testdata/upstream/.
- Distinctive: line 81
Commit the sanitized request, raw SSE, and parsed fixture when they are needed to justify the implementation.
- Distinctive: line 83
Keep backlog/spec wording conservative until the fixture-backed behavior is implemented and tested.
- Distinctive: line 101
Do not add absolute local filesystem paths to docs, backlog items, comments, or examples.
- Distinctive: line 103
When linking to files from repo markdown, prefer relative markdown links.
- Distinctive: line 109
Treat it as the frozen V2 release ledger, not as a live scratch backlog.
- Distinctive: line 110
Keep shipped scope and non-goals aligned with the actual router, handlers, tests, and OpenAPI.
- Very specific: line 112
If parity is only partial, document that boundary in docs/compatibility-matrix.md instead of silently widening the V2 claim.
- Distinctive: line 115
Use exact dates when re-validating the scope wording against docs.
- Distinctive: line 119
Do not move work out of V2 merely because exact hosted parity is unavailable.
- Distinctive: line 120
If public docs define a core behavior for a surface already claimed by V2, and the missing behavior materially affects practical …
- Very specific: line 123
Use docs/compatibility-matrix.md as the live source of truth for status labels such as Implemented, Broad subset, Shim-owned, and V3.
- Very specific: line 126
Use docs/v3-scope.md for parity-expansion or backend- expansion work that is useful but not required for the current V2 contract.
- Very specific: line 128
Use docs/v4-scope.md for shim-owned extensions and plugin/backend architecture that should not be framed as OpenAI API parity.
- Very specific: line 133
Keep docs/work-queue.md as the live next-work index.
- Distinctive: line 134
When a task starts, finishes, is parked, or materially changes priority, update the queue in the same change or explicitly say why it was …
- Distinctive: line 136
Do not create git commits unless the user explicitly asks to commit in the current turn.
- Distinctive: line 139
Do not use the work queue as a compatibility matrix, evidence report, or design document.
- Very specific: line 142
When adding, removing, or changing operator entrypoints, update docs/script-inventory.md or the relevant guide in the same change.
- Very specific: line 145
When a new practical workflow emerges, prefer a guide under docs/guides/ over repeating command blocks across many scope documents.
- Very specific: line 153
Treat include support carefully.
- Distinctive: line 155
Treat retrieve streaming separately from create streaming.
- Very specific: line 157
Treat input_items as “items used to generate the response”, not just the current request body.
- Very specific: line 182
Keep llama.providers, .env.example, Codex metadata, compatibility hooks, provider matrix docs, ops evidence, and docs/work-queue.md aligned …
- Very specific: line 188
Use the public provider/model alias in operator-facing docs and evidence.
- Distinctive: line 190
Do not promote a model candidate from memory, marketing names, or old logs.
- Distinctive: line 191
Verify the exact live provider/local-runtime model id and keep evidence attached to the promotion decision.
- Distinctive: line 201
Do not add undocumented public limits to OpenAI-compatible endpoints just to stop memory growth.
- Distinctive: line 208
If a limit is only needed for optional shim-owned side effects (shadow-store, replay artifact persistence, debug capture, local snapshots), …
- Very specific: line 215
Do not use io.ReadAll, unbounded strings.Builder, full-table slices, or per-item event accumulation on public or attacker-reachable paths …
- Distinctive: line 224
If a list endpoint does not return file or blob content, do not read content from storage just to build the page.
- Distinctive: line 226
If a replay path writes SSE incrementally, do not prebuild the full replay event list in memory.
- Distinctive: line 231
When a bug is caused by full buffering, replay synthesis, or list/rebuild logic, review all sibling entrypoints that share the helper or …
- Distinctive: line 233
Do not mark a fix done if one path is bounded but another equivalent path still materializes the same data.
- Distinctive: line 244
Do not present Python monkeypatching, builtin wrapping, substring blacklists, or planner hints as real sandboxing.
- Distinctive: line 249
If a shim-local safety layer is only advisory or best-effort, document it as such and do not overclaim filesystem/module isolation.
- Distinctive: line 258
If the limit affects only internal behavior, document it in repo docs/config, not as an OpenAI contract change.
- Distinctive: line 278
If a patch removes only one amplification factor but leaves the same attack path reachable through another buffer, scan, rebuild, or replay …
- Distinctive: line 298
Add the following where applicable:
- Very specific: line 300
If changing list pagination: test after, order, has_more, and that large unused fields are not read.
- Distinctive: line 302
If changing replay/SSE: test create-stream, retrieve-stream, and any synthetic replay helper.
- Distinctive: line 304
If changing shadow-store/capture behavior: test that overflow skips local persistence without breaking the client response.
- Distinctive: line 307
If changing code interpreter/container behavior: test owner isolation, adversarial input paths, and both metadata and content handling.
- Distinctive: line 310
If changing vector store indexing: test attach, update, delete, and rebuild/repair behavior separately.
- Distinctive: line 315
Before merging work in these areas, explicitly ask and answer:
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS
Scope
This repository is an OpenAI-compatible shim. Any task that touches /v1/responses, /v1/conversations, /v1/chat/completions, OpenAPI, backlog status, or compatibility claims must be checked against current official OpenAI docs before it is marked done.
Required verification workflow
Use this order every time:
- Start with the local docs index at
openapi/llms.txt. Use it as a map of relevant official pages only. It is not the source of truth for exact request or response contracts. https://developers.openai.com/api/docs/llms.txt chech update if needed. - Use OpenAI Docs MCP tools against
developers.openai.comandplatform.openai.com. Search first, then fetch the exact page or section you need. - Do a final spot-check on the official site directly for the exact page or endpoint you are validating. Prefer only official OpenAI domains.
- If MCP and the official site disagree, or MCP is thin, ambiguous, or missing exact schema details, treat the current official site page as the tie-breaker and update the backlog/spec conservatively.
For Codex CLI compatibility work, also inspect
openai/codex as an implementation
reference after the official-docs check. Use it to understand the actual
Codex agent tool registry, feature flags, model metadata, transport choices,
and request shape. It is not a substitute for official API docs and must not
be used as the source of truth for OpenAI wire-contract claims. If no local
checkout is available, clone it into an ignored temporary directory such as
.tmp/codex-upstream/, inspect the relevant files, and do not commit the
checkout.
Do not close a compatibility task from memory alone.
Choreography diagram upkeep
Keep docs/engineering/openai-api-choreography-atlas.md
aligned with implementation and compatibility boundaries. If a change affects
Responses state flow, SSE event flow, retrieve-stream replay, WebSocket
transport, tool routing, native coding tools, Codex CLI behavior, compaction,
or routing-mode semantics, update the relevant Mermaid diagram and nearby text
in the same change. Before marking the task done, re-check that the atlas does
not overclaim beyond docs/compatibility-matrix.md
and the official-docs/fixture evidence used for the change.
What must be checked
For any OpenAI-surface task, verify all of these that apply:
- endpoint existence and HTTP method
- path params, query params, and defaults
- request body shape and limits
- response shape, including nested object form
- pagination semantics
- streaming event flow and event payload fields
- retention and storage semantics
- error behavior and unsupported-field behavior
Do not mark a task done if only the route exists but the documented semantics still differ.
When fixtures are mandatory
Use a real upstream fixture before closing parity work when any of the following is true:
- the task depends on exact SSE choreography rather than only final JSON shape
- the public docs confirm an item family exists but do not fully specify event order or event payload fields
- the task changes stored replay or retrieve streaming fidelity for hosted or native tools
- the task depends on exact artifact placement, annotation placement, or intermediate tool-progress events
- the task depends on exact failure/status semantics and the docs do not pin down whether the upstream surface completes, fails, or returns partial data
- MCP/OpenAI docs search, API reference, and the live public site disagree or leave a material ambiguity about observable wire behavior
In those cases:
- Add or reuse a request template under
internal/httpapi/testdata/upstream/. - Capture a real upstream trace with
cmd/upstream-sse-capture. - Commit the sanitized request, raw SSE, and parsed fixture when they are needed to justify the implementation.
- Keep backlog/spec wording conservative until the fixture-backed behavior is implemented and tested.
Typical examples where fixtures are expected:
- tool-specific
response.*SSE families - hosted/native tool replay parity
code_interpreter_call.outputsor artifact/citation behaviorresponse.failedvsresponse.completedambiguity- image-generation partial events
Fixtures are not mandatory when the public docs and reference already define the relevant contract well enough and the shim is only implementing a generic/docs-backed subset without claiming exact hosted choreography.
Path hygiene
- In committed repo files, use repo-relative paths only.
- Do not add absolute local filesystem paths to docs, backlog items, comments, or examples.
- When linking to files from repo markdown, prefer relative markdown links.
V2 scope rules
When updating docs/v2-scope.md:
- Treat it as the frozen V2 release ledger, not as a live scratch backlog.
- Keep shipped scope and non-goals aligned with the actual router, handlers, tests, and OpenAPI.
- If parity is only partial, document that boundary in
docs/compatibility-matrix.mdinstead of silently widening the V2 claim. - Use exact dates when re-validating the scope wording against docs.
Scope triage rules
- Do not move work out of V2 merely because exact hosted parity is unavailable. If public docs define a core behavior for a surface already claimed by V2, and the missing behavior materially affects practical functionality, keep it in V2 as a conservative shim-local subset.
- Use
docs/compatibility-matrix.mdas the live source of truth for status labels such asImplemented,Broad subset,Shim-owned, andV3. - Use
docs/v3-scope.mdfor parity-expansion or backend- expansion work that is useful but not required for the current V2 contract. - Use
docs/v4-scope.mdfor shim-owned extensions and plugin/backend architecture that should not be framed as OpenAI API parity.
Work queue and planning hygiene
- Keep
docs/work-queue.mdas the live next-work index. When a task starts, finishes, is parked, or materially changes priority, update the queue in the same change or explicitly say why it was not updated. - Do not create git commits unless the user explicitly asks to commit in the current turn. After editing and verification, show the changed files, verification result, and suggested commit message, then wait for approval.
- Do not use the work queue as a compatibility matrix, evidence report, or design document. Keep rows short and link to the detailed scope, runbook, or engineering document.
- When adding, removing, or changing operator entrypoints, update
docs/script-inventory.mdor the relevant guide in the same change. - When a new practical workflow emerges, prefer a guide under
docs/guides/over repeating command blocks across many scope documents.
Implementation rules for this repo
- For Responses and Conversations work, check both guide pages and API reference pages. Guides explain semantics; reference pages define contract details.
- Treat
includesupport carefully. “Accepted as compatibility no-op” is not the same as fully implemented semantics. - Treat retrieve streaming separately from create streaming. Route parity is not enough; replay event fidelity matters.
- Treat
input_itemsas “items used to generate the response”, not just the current request body. - For constrained custom tools, distinguish between: shim-local supported subset, repair/validation compatibility layer, and true constrained decoding/runtime parity.
- For
responses.mode, verify behavior inprefer_local,prefer_upstream, andlocal_onlywhen the task changes fallback behavior. - For compaction or other cross-turn state-carrying features, verify all of:
non-stream create, create-stream, retrieve-stream,
previous_response_id,conversation,/v1/responses/{id}/input_items, andresponses.mode. - For tool-routing work, distinguish between:
shim-local subset,
proxy-only compatibility bridge,
and exact hosted parity.
In particular, keep
mcp.server_urlseparate frommcp.connector_id, and keep hosted/servertool_searchseparate from client-executedtool_search_outputflows. - For stored Chat Completions work, treat these as separate scopes: local shadow-store ownership, streamed shadow-store reconstruction, and optional upstream history merge/bridge behavior.
Provider/model operations
- New provider/model aliases must follow
docs/guides/add-provider-model.md. - Keep
llama.providers,.env.example, Codex metadata, compatibility hooks, provider matrix docs, ops evidence, anddocs/work-queue.mdaligned when an alias changes status. - Distinguish server-side upstream provider tokens
(
llama.providers[].bearer_token_env) from shim ingress auth used by clients, Codex eval, and external testers. - Use the public
provider/modelalias in operator-facing docs and evidence. Record raw upstream model ids only as implementation detail. - Do not promote a model candidate from memory, marketing names, or old logs. Verify the exact live provider/local-runtime model id and keep evidence attached to the promotion decision.
Mandatory security and regression guardrails
The commit range re-validated on 2026-04-19 exposed a repeating set of mistakes. Treat the following as mandatory rules for new work on this repo.
1. Do not fix DoS by adding hidden OpenAI-surface regressions
- Do not add undocumented public limits to OpenAI-compatible endpoints just to stop memory growth.
- In particular, do not add shim-only caps such as:
undocumented
limitmaxima, undocumented response-size ceilings, or new502/validation failures for payloads that are still valid per the official OpenAI surface. - If a limit is only needed for optional shim-owned side effects (shadow-store, replay artifact persistence, debug capture, local snapshots), keep it internal-only, configurable, and non-fatal for the main client response path.
2. Avoid full materialization on hot request, replay, list, and rebuild paths
- Do not use
io.ReadAll, unboundedstrings.Builder, full-table slices, or per-item event accumulation on public or attacker-reachable paths unless the data is already hard-bounded by contract and tests prove it. - Prefer:
streaming transforms over buffer-then-rewrite,
visitor/callback emission over
[]eventconstruction, metadata-first scans over full BLOB/file reads, SQL/keyset pagination over load-all-then-slice, incremental updates over full rebuilds. - If a list endpoint does not return file or blob content, do not read content from storage just to build the page.
- If a replay path writes SSE incrementally, do not prebuild the full replay event list in memory.
3. Fix every reachable sibling path, not just the first hot path you saw
- When a bug is caused by full buffering, replay synthesis, or list/rebuild logic, review all sibling entrypoints that share the helper or pattern.
- Do not mark a fix done if one path is bounded but another equivalent path still materializes the same data.
- Typical sibling pairs to check in this repo: create-stream vs retrieve-stream, stored replay vs synthetic replay, local list path vs merged upstream bridge path, Docker snapshot path vs unsafe-host/local snapshot path, attach/update path vs delete/rebuild path.
4. Do not rely on fake language-level sandboxes as a security boundary
- Do not present Python monkeypatching, builtin wrapping, substring blacklists, or planner hints as real sandboxing.
- For code interpreter security, the real boundary is the runtime/container isolation layer. Prefer Docker hardening and explicit docs over fragile Python-level wrappers.
- If a shim-local safety layer is only advisory or best-effort, document it as such and do not overclaim filesystem/module isolation.
5. Keep limits centralized and docs-aware
- New operational limits belong in normalized config/service limit structs, not
scattered
constvalues hidden inside handlers. - Wire new limits through config defaults, runtime normalization, tests, and example config together.
- If the limit affects only internal behavior, document it in repo docs/config, not as an OpenAI contract change.
6. Prefer conservative architecture over narrow patches
- For storage/listing: use SQL-side filtering/pagination where possible, use cursor/keyset pagination instead of load-all pagination, avoid reading unused columns.
- For retrieval/vector indexing: prefer incremental row updates or coalesced repair/rebuild paths over full rebuild-on-every-mutation.
- For snapshots and generated-artifact diffing: compare metadata first and fetch content lazily only for bounded candidates.
- For sanitization: prefer streaming/token-based rewriting over buffer -> unmarshal -> marshal of the whole payload.
7. Do not close partial mitigations as complete fixes
- If a patch removes only one amplification factor but leaves the same attack path reachable through another buffer, scan, rebuild, or replay path, keep the task open or split the remaining work into an explicit follow-up.
- Backlog, OpenAPI, README, and guides must not claim full closure if the code only implements a bounded subset or best-effort mitigation.
8. Mandatory tests for this class of changes
For any security, replay, pagination, storage, sandbox, or resource-bound fix, the minimum bar is:
- focused unit tests for the new bound/streaming/helper behavior
- integration tests for the public endpoint happy path
- integration tests for the main oversized/adversarial path
- tests that the client-visible OpenAI contract did not regress
- tests for all sibling paths that share the same helper/pattern
go test ./...make lintgit diff --check
Add the following where applicable:
- If changing list pagination:
test
after,order,has_more, and that large unused fields are not read. - If changing replay/SSE: test create-stream, retrieve-stream, and any synthetic replay helper.
- If changing shadow-store/capture behavior: test that overflow skips local persistence without breaking the client response.
- If changing code interpreter/container behavior: test owner isolation, adversarial input paths, and both metadata and content handling.
- If changing vector store indexing: test attach, update, delete, and rebuild/repair behavior separately.
9. Review checklist before merge
Before merging work in these areas, explicitly ask and answer:
- Did this fix remove the root cause, or only cap one manifestation?
- Did we accidentally change the public OpenAI contract to make the fix easier?
- Did we move the same bug to a sibling path?
- Is the bound internal-only and best-effort, or is it a real API behavior?
- Are docs, OpenAPI, config defaults, and tests aligned with that answer?
Before calling a task done
For docs-only or process-only changes that do not modify implementation,
OpenAPI, public compatibility claims, or operator behavior, narrow verification
to path hygiene, docs/backlog alignment, git diff --check, and make lint.
Explicitly say that no runtime code path changed.
Confirm all of the following:
- router/handler/service/storage behavior matches the intended scope
openapi/openapi.yamlmatches the implementation- integration tests cover the happy path and the main contract edges
go test ./...passes- backlog wording does not overclaim beyond what the code and docs actually support
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

