Skip to content

feat(llm-calls): inline LLM calls view (#371) - #217

Closed
alex-astafyev wants to merge 6 commits into
developfrom
feature/371-llm-calls-view
Closed

alex-astafyev wants to merge 6 commits into
developfrom
feature/371-llm-calls-view

Conversation

@alex-astafyev

@alex-astafyev alex-astafyev commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds an LLM calls view across workflow runs and standalone sessions, replacing the previously planned standalone pages with inline, collapsible panels that keep context visible.

Workflow run show page

  • New LLM Calls tab alongside existing Overview / Assets tabs
  • Client-side Model and Session filters (Select dropdowns)
  • Aggregated from all step sessions in the run

Session show pages (project-scoped and company-scoped)

  • Collapsible LLM Calls panel (chevron + badge count, matching Terminal Session Log style)
  • Client-side Model filter when multiple models are present
  • Only shown for terminal (finished/failed/cancelled) sessions with data

Shared LlmCallsTable component

  • Columns: Time (date+time in browser timezone), Model (badge), Input/Output/Cache tokens, Cost
  • 3-decimal cost formatting for sub-dollar amounts
  • Optional Session column for workflow run context

Backend

  • LlmCall model, LlmCallResource, LlmCallsQuery service
  • Migration creating llm_calls table with indexes
  • Controllers pass llm_calls as Inertia props (sessions + workflow runs)
  • materialize_llm_calls on TerminalSession (from usage_statistics.events_data)
  • Backfill rake task (llm_calls:backfill) for historical data

OTLP ingest: optional JSON proxy forwarding

  • New OTLP_INGEST_PROXY_URL env var: when set, forwards every incoming metrics/logs payload as JSON to the configured URL (best-effort — proxy errors are logged but don't affect the client response)
  • Exposes OTLP_INGEST_PORT / OTLP_INGEST_WEB_BASE_URL / OTLP_INGEST_PROXY_URL in docker-compose so .env values reach the container
  • Adds debug profile service otlp-proxy-consumer (mendhak/http-https-echo) for local inspection of forwarded payloads

Agent type identification in OTLP

  • Injects agent_type into OTEL_RESOURCE_ATTRIBUTES for all agent adapters (claude_code, gemini_cli, codex) so third-party OTLP consumers can identify the originating CLI without Rails-side context

Bug fixes (discovered during development)

  • GrokAdapter#decode_body: base64-decoded binary responses (e.g. /v1/bundle/archive) crashed extract_events_from_mitm with invalid byte sequence in UTF-8, silently losing all Grok usage data. Fixed with .scrub("").
  • TerminalSession#materialize_llm_calls: ISO8601 timestamps from MITM-sourced events were parsed as epoch-ms, producing 1970 dates. Fixed with format detection.

Test plan

  • LlmCallsTable unit tests (formatting, column visibility, filtering)
  • SessionShowContent tests (llmCalls prop, all session states)
  • ShowPage tests (project + company session pages)
  • WorkflowRun ShowPage tests (LLM Calls tab)
  • LlmCall model tests
  • LlmCallResource tests
  • LlmCallsQuery service tests
  • TypeScript compiles cleanly
  • Verified Grok session LLM calls render with correct timestamps
  • Verified OTLP proxy forwarding end-to-end (otlp-proxy-consumer echo server)
  • Verified agent_type attribute appears in forwarded OTLP payloads

🤖 Generated with Claude Code

@alex-astafyev
alex-astafyev marked this pull request as draft September 7, 2026 11:03
@alex-astafyev
alex-astafyev force-pushed the feature/371-llm-calls-view branch 7 times, most recently from 302ed6a to b41352a Compare September 7, 2026 12:04
@artempartos

Copy link
Copy Markdown
Contributor

Do we capture all data provided?

@alex-astafyev

Copy link
Copy Markdown
Collaborator Author

Do we capture all data provided?

I could try this with Claude Code, Cursor CLI, Grok CLI, and Gemini CLI.
It could capture tokens usage (see screenshots).

@alex-astafyev
alex-astafyev marked this pull request as ready for review September 7, 2026 18:47
@alex-astafyev
alex-astafyev force-pushed the feature/371-llm-calls-view branch 3 times, most recently from ceb85c0 to 9820ba3 Compare September 11, 2026 14:04
@alex-astafyev
alex-astafyev force-pushed the feature/371-llm-calls-view branch from 73a8a78 to dfb304b Compare September 16, 2026 10:39
@Evgeniy-DB
Evgeniy-DB force-pushed the feature/371-llm-calls-view branch from 720f8b4 to 7b3c8c7 Compare October 12, 2026 07:44
alex-astafyev and others added 5 commits October 14, 2026 09:38
Add LLM call materialization, query service, and resource layer.
Surface calls as inline collapsible panels on workflow run (tab) and
session (panel) show pages with client-side Model/Session filters.

Remove the standalone workflow run LLM calls page and route.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
…ection

GrokAdapter#decode_body crashed on base64-decoded binary responses
(e.g. /v1/bundle/archive) because force_encoding("UTF-8") left invalid
byte sequences that blew up body.blank? — killing the entire
extract_events_from_mitm and silently losing all usage data for the
session. Fix: scrub invalid bytes after decoding.

TerminalSession#materialize_llm_calls assumed timestamps were always
epoch-milliseconds, but MITM-sourced events carry ISO8601 strings —
.to_i on "2026-09-07T16:54:42Z" yields 2026, producing 1970 dates.
Fix: detect the format and parse accordingly.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
…attribute

- Add OTLP_INGEST_PROXY_URL env var to otlp-ingest: when set, forwards
  every incoming metrics/logs payload as JSON to the configured URL
  (best-effort — proxy errors are logged but don't affect the client response)
- Expose OTLP_INGEST_PORT/WEB_BASE_URL/PROXY_URL in docker-compose so
  .env values are passed into the container
- Add debug profile service otlp-proxy-consumer (mendhak/http-https-echo)
  for local inspection of forwarded payloads
- Inject agent_type into OTEL_RESOURCE_ATTRIBUTES for all agent adapters
  (claude_code, gemini_cli, codex) so third-party consumers can identify
  the originating CLI without Rails-side context

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
@Evgeniy-DB
Evgeniy-DB force-pushed the feature/371-llm-calls-view branch from 7b3c8c7 to a022fa7 Compare October 14, 2026 07:42
SessionKey.resource_attributes now appends agent_type to the telemetry
resource attributes. Update the stale kiro_cli_adapter and
agent_session_strategy expectations to match.

Signed-off-by: Evgeniy Yagnenkov <[email protected]>
NOX73 added a commit that referenced this pull request Nov 10, 2026
…nd release endpoints, and self-update with an opt-out (task #217) (#676)

* feat(runners): the platform's runner pins, release endpoints and self-update (task #217)

Signed-off-by: Alex <[email protected]>

* feat(runners): the runner image Dockerfile, gofmt

Signed-off-by: Alex <[email protected]>

* docs(runners): PROTOCOL.md release endpoints and update, releasing.md runner compatibility, DESIGN row 10

Signed-off-by: Alex <[email protected]>

* fix(runners): read the machine for an update offer only when a newer version is recommended

Signed-off-by: Alex <[email protected]>

* fix(runners): Fix CR round 1 of the runner release lane

- update.DownloadTimeout is 2 minutes; DESIGN.md 14.4 says a session
  assigned during an update starts after the restart (no reservation)
- the release requests carry neither protocol header, and the Go
  conformance harness checks each header's presence or absence
- a download_url template that format cannot fill in fails boot
- a runner version over 255 characters is invalid_registration before
  the min_version refusal
- the published image sets AIXLE_RUNNER_NO_SELF_UPDATE=1
- the parsed pins are memoized; a test sends real pins through the
  Config gem
- renumber the auto_update migration, which collided with develop's

Signed-off-by: Alex <[email protected]>

* style(runner): gofmt the conformance harness

Signed-off-by: Alex <[email protected]>

* test(runners): load the Config gem pins through load_files

Signed-off-by: Alex <[email protected]>

* fix(runners): Fix CR round 2 of the runner release lane

- The release endpoints answer Cache-Control: no-store before validation,
  so the 400 and 404 refusals carry it too (PROTOCOL.md §2).
- The update offer is {version, sha256}: the runner builds its release
  requests from its own platform URL, so url is dropped.
- configure treats AIXLE_RUNNER_NO_SELF_UPDATE as --no-auto-update.
- The host runner computes its effective self-update flag once.

Signed-off-by: Alex <[email protected]>

* style(runner): gofmt configure's options

Signed-off-by: Alex <[email protected]>

* Add runner release workflow.

Signed-off-by: Rozhnov Alexandr <[email protected]>

---------

Signed-off-by: Alex <[email protected]>
Signed-off-by: Rozhnov Alexandr <[email protected]>
Co-authored-by: Alex <[email protected]>
aixle-com Bot pushed a commit that referenced this pull request Nov 10, 2026
…-callback-proxy

Resolved per Alex's decisions (task #216, comment 72539):
- PROTOCOL.md: develop keeps §5.6 (releases) and §5.7 (checksums); the
  callback proxy becomes §5.8, and every reference to it is updated.
- HostOptions.Binary has one meaning: the runner's own executable, symlinks
  resolved, which a self-update replaces and the proxy sidecar runs. One
  resolver (update.BinaryPath); ownBinary is dropped.
- main.go: the host/proxy mode switch, with host still passing NoSelfUpdate.
- client.go: develop's do/newRequest and the branch's Proxy with its own
  non-redirecting client.
- conformance_test.go: both harness changes; the protocol-header presence
  checks apply to the proxy fixtures too.
- routes, process-mode route test, fixtures README and DESIGN.md: both sides.

Signed-off-by: Alex <[email protected]>
artempartos added a commit that referenced this pull request Nov 11, 2026
Every runtime's usage now becomes one llm_calls row per model call, in one
vocabulary: provider, source, granularity and a cost basis that says whether
the cost was reported, estimated from list prices, converted from credits or
is unknown. Unknown tokens and costs are null, never zero.

- Materialization moves to LlmCalls::Materializer and runs on the cleanup
  path too: AdmittedPhaseActivity settles the state with a direct write, so
  the on_finished callback PR #217 relied on never ran for most sessions.
  Rows are keyed by their event's position and never rewritten, so a rerun
  or the backfill task only adds what is missing.
- One price table (config/llm_prices.yml, LlmCalls::Pricing) estimates the
  calls whose runtime reports tokens but no cost; Antigravity's in-adapter
  table moved into it and Grok feeds it the xAI catalogue. Codex and Gemini
  CLI were recorded at $0.
- Codex, Gemini CLI, Grok and Antigravity count cached input inside input;
  their adapters now subtract it, as Claude Code and Copilot already did.
- One model normalizer strips routing and Bedrock prefixes.

Design: docs/design/insights-usage-export.md, section 3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
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.

3 participants