Commit 2b20dfa
feat: OpenRouter audit passthrough + model_config hotfix (#20)
* feat(core): add LlmAudit type and audit field on Event::UserMessage
Introduces `LlmAudit` (user/session_id/metadata, all optional) as a
transport-only passthrough struct; extends `Event::UserMessage` with
`#[serde(default)] audit: Option<LlmAudit>` for zero-churn on legacy
wire bodies. Extends `ChatResponse` with generation_id/model/usage
fields (all None for now; Task 7 fills them from LLM responses).
Updates pde.rs test helper and both companion.rs construction sites.
Refactors pipeline::run to own the full llm_resp rather than destructure.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(llm): add AppAttribution headers to OpenRouterClient
Introduces `AppAttribution` struct with optional `HTTP-Referer` and
`X-Title` fields. `OpenRouterClient::new` now takes attribution as a
second argument; invalid header values are warned and dropped rather
than panicking. Adds `with_base_url` constructor for wiremock-based
unit tests. Production call site reads `OPENROUTER_APP_REFERER` /
`OPENROUTER_APP_TITLE` env vars at startup.
* feat(llm): add user/session_id/metadata passthrough to ChatRequest
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(llm): parse generation_id/model/usage from OpenRouter response
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(pipeline): thread LlmAudit from Event into ChatRequest
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(pipeline): propagate usage/generation_id/model into ChatResponse + tracing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(api): add audit passthrough on send_message + usage on response
- Add `LlmAuditDto` DTO and `validate_llm_audit` helper with four
constants (string chars ≤ 256, metadata keys ≤ 16, key chars ≤ 64,
value chars ≤ 512).
- Wire validated `audit` into both `send_message` and `send_message_async`
handlers (replaces the Task-1 `audit: None` placeholder).
- Extend `CompanionReplyResponse` with optional `usage`, `generation_id`,
and `model` fields sourced from the pipeline `ChatResponse`.
- Add 8 `validate_llm_audit_*` unit tests (all pass without DB) and
4 `send_message_async_*` sqlx integration tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs(env): document OPENROUTER_APP_REFERER and OPENROUTER_APP_TITLE
Two optional env vars added in Task 2 of the openrouter-audit plan.
When set, the engine emits HTTP-Referer / X-Title headers on every
outbound OpenRouter call so the deployment shows up in OpenRouter's
app analytics. Both unset preserves today's anonymous behaviour.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs(api): document audit passthrough + usage on CompanionReplyResponse
Updated the success-response JSON example to show the three new
optional echo fields (usage / generation_id / model). Added two new
sub-sections after the prompt_traits section describing the audit
passthrough body field and the size/shape caps. Notes that the async
route accepts audit but does not surface the echo fields.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs: add llm-audit reference (EN + ZH)
One-page docs for the OpenRouter audit passthrough surface. Covers
the inbound audit request field with cap table, the outbound usage
echo on sync responses, the two App-Attribution env vars, observability
behaviour, and the explicit non-goals (no persistence, no hashing, no
sanitisation, no interpretation).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(openapi): regenerate snapshot for audit + usage fields
Picks up LlmAuditDto, the audit field on SendMessageRequest, and the
three optional usage / generation_id / model fields on
CompanionReplyResponse added in Task 8 of the openrouter-audit plan.
CI drift check will be green after this.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(openapi): strip cargo stderr lines from snapshot
The regeneration script was run without `--quiet`, which caused two
cargo progress lines to be prepended to the JSON file. The CI
`openapi-snapshot` job uses `--quiet` and diffs against this file, so
the snapshot would have failed on merge.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(model_config): retire stale OpenRouter model IDs (#19)
OpenRouter retired several model IDs that were hard-coded in the
example config, causing prod `POST /comp/chat/:id/message` calls to
fail with 400 "is not a valid model ID":
- x-ai/grok-4-fast → x-ai/grok-4.20
- x-ai/grok-4-mini → x-ai/grok-4.1-fast
- deepseek/deepseek-chat-v3.2 → x-ai/grok-4.1-fast (or
deepseek/deepseek-v4-flash on insight tasks)
Also leaves a TODO inline noting that `fallback` should grow into a
preference-ordered list in a future iteration; for now one fallback
per task is all we wire.
Hardcoded defaults in `crates/eros-engine-llm/src/model_config.rs`
still reference the retired IDs — out of scope for this hotfix and
should be a separate follow-up.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 657291c commit 2b20dfa
18 files changed
Lines changed: 1437 additions & 38 deletions
File tree
- crates
- eros-engine-core/src
- eros-engine-llm
- src
- eros-engine-server
- src
- pipeline
- routes
- docs
- examples
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
| |||
28 | 43 | | |
29 | 44 | | |
30 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
31 | 52 | | |
32 | 53 | | |
33 | 54 | | |
| |||
75 | 96 | | |
76 | 97 | | |
77 | 98 | | |
78 | | - | |
79 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
80 | 104 | | |
81 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
82 | 109 | | |
83 | 110 | | |
84 | 111 | | |
| |||
116 | 143 | | |
117 | 144 | | |
118 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
119 | 188 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
0 commit comments