Skip to content

LLM → Telemetry: fixes#638

Merged
xingyaoww merged 3 commits into
mainfrom
fix/llm-telemetry-pricing
Oct 5, 2025
Merged

LLM → Telemetry: fixes#638
xingyaoww merged 3 commits into
mainfrom
fix/llm-telemetry-pricing

Conversation

@enyst
Copy link
Copy Markdown
Member

@enyst enyst commented Oct 4, 2025

Addresses a few things from #637

  • LLM → Telemetry:
    • forward input_cost_per_token/output_cost_per_token so that it's actually used for custom cost
  • Telemetry logging:
    • de-duplicate tools (drop kwargs.tools)
    • serialize raw_response with model_dump() when available
    • use unique filenames with a short UUID suffix.
  • Telemetry cost:
    • intentionally skip recording 0.0; added inline comment clarifying policy.

All tests pass locally (1480 passed). Larger refactors from #637 are deferred to a follow-up.


Agent Server images for this PR

GHCR package: https://github.com/All-Hands-AI/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Base Image Docs / Tags
golang golang:1.21-bookworm Link
java eclipse-temurin:17-jdk Link
python nikolaik/python-nodejs:python3.12-nodejs22 Link

Pull (multi-arch manifest)

docker pull ghcr.io/all-hands-ai/agent-server:5ea2ff6-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-5ea2ff6-python \
  ghcr.io/all-hands-ai/agent-server:5ea2ff6-python

All tags pushed for this build

ghcr.io/all-hands-ai/agent-server:5ea2ff6-golang
ghcr.io/all-hands-ai/agent-server:v1.0.0_golang_tag_1.21-bookworm_golang
ghcr.io/all-hands-ai/agent-server:5ea2ff6-java
ghcr.io/all-hands-ai/agent-server:v1.0.0_eclipse-temurin_tag_17-jdk_java
ghcr.io/all-hands-ai/agent-server:5ea2ff6-python
ghcr.io/all-hands-ai/agent-server:v1.0.0_nikolaik_s_python-nodejs_tag_python3.12-nodejs22_python

The 5ea2ff6 tag is a multi-arch manifest (amd64/arm64); your client pulls the right arch automatically.

Comment thread openhands/sdk/llm/utils/telemetry.py Outdated
@enyst enyst changed the title LLM → Telemetry: forward custom pricing; document zero-cost skip LLM → Telemetry: fixes Oct 4, 2025
Comment thread openhands/sdk/llm/utils/telemetry.py Outdated
Comment thread openhands/sdk/llm/utils/telemetry.py Outdated
@enyst
Copy link
Copy Markdown
Member Author

enyst commented Oct 4, 2025

@OpenHands Look at the diff of this branch with main, and remember it. Then merge main branch into this PR's branch. Pay attention to the incoming changes, they affect telemetry. Adapt our changes, commit and push.

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Oct 4, 2025

I'm on it! enyst can track my progress at all-hands.dev

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Oct 4, 2025

Final summary of work completed

What I did

  • Reviewed and memorized the diff of fix/llm-telemetry-pricing vs main, focusing on telemetry-related changes.
  • Merged origin/main into fix/llm-telemetry-pricing.
  • Verified the merged code preserved and aligned telemetry behavior:
    • LLM passes input_cost_per_token and output_cost_per_token into Telemetry.
    • Telemetry cost calculation uses LiteLLM headers when present; otherwise falls back to litellm cost calculator with custom_cost_per_token when provided.
    • Skips recording zero cost values.
    • Logging uses unique filenames with a short UUID suffix.
    • Logging serializes responses safely via a centralized _safe_json (ModelResponse -> model_dump with redaction; fallbacks for other objects).
    • De-duplicates duplicated tools by removing kwargs["tools"] when also present at top-level.
  • Built and ran the full test suite: 1513 passed, no new failures.
  • Amended the merge commit to include Co-authored-by and pushed to the PR branch.

Checklist

  • Retrieved and reviewed the diff against main and kept telemetry changes in mind.
  • Merged main into the PR branch.
  • Ensured telemetry-related incoming changes are respected and compatible.
  • Verified with a full build and test run (1513 passed).
  • Committed (amended) with Co-authored-by and pushed to origin.

Conciseness and scope

  • No extraneous code changes were added beyond the merge; existing telemetry adaptations remained valid and required no further edits.

Details

  • Branch: fix/llm-telemetry-pricing
  • Latest commit pushed: 7839af2 (Merge remote-tracking branch 'origin/main' into fix/llm-telemetry-pricing)
  • Tests: uv run pytest -q → 1513 passed (warnings unchanged/benign)

View full conversation

@enyst enyst marked this pull request as draft October 4, 2025 22:32
…safer logging, unique filenames, tools de-dup, skip zero-cost

- Rebased branch content by hard-resetting to origin/main then applying our telemetry improvements on top
- LLM passes input/output cost per token into Telemetry
- Telemetry uses LiteLLM header cost first, falls back to litellm completion_cost with custom_cost_per_token
- Telemetry logging uses _safe_json, redacts sensitive values, and adds short-UUID filename suffix; de-duplicates tools
- Skip recording 0.0 cost to avoid noise

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst enyst force-pushed the fix/llm-telemetry-pricing branch from 7839af2 to 4de4a62 Compare October 4, 2025 22:43
Comment thread openhands/sdk/llm/utils/telemetry.py Outdated
@enyst enyst marked this pull request as ready for review October 5, 2025 09:06
@xingyaoww xingyaoww merged commit 897d4e9 into main Oct 5, 2025
16 checks passed
@xingyaoww xingyaoww deleted the fix/llm-telemetry-pricing branch October 5, 2025 18:49
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