feat(admin-costs): content-free per-user conversation list and session profile - #1093
Merged
Merged
Conversation
…n profile
Adds the missing drill-down between "top users by cost" and the per-session
cost anatomy: an admin starts from a user, lists their conversations without
reading any of them, and opens one for the diagnostic profile a developer (or
a model handed the JSON) needs to find cost-effectiveness work.
- apis/shared/observability/content_policy.py: the denylist of every
content-bearing attribute on the session/cost/upload row families, three
aliased allowlist projections, and walkers. Enforced by a test that walks
every admin cost response model (one named exemption: TopSessionCost.title,
kept by decision) and a moto test that seeds content and proves none of it
returns.
- GET /admin/costs/users/{id}/sessions and GET /admin/costs/sessions/{id}/profile
(scope admin.costs). Unrecorded cost renders costKnown=false, never $0.
- admin/costs/diagnoses.py: 15 pure rules encoding the classifications prior
quota investigations reached by hand (prefix spiral, partial-miss heavy,
over-threshold, summary over budget, prompt/toolConfig mutation, agent-cache
bypass, attachment-heavy, ...), each with numeric evidence and the fix.
- get_session_cost_records now projects the twelve attributes the anatomy
consumes, closing the citations[].text read on the existing path.
- Top-users enrichment (email, tier, quota %) replaces a hard-coded None.
No new table, no GSI operation, no feature flag (read-only, admin-only,
degrades to "not tracked"). Adds an app-api-branch launch config (:8010) so a
branch can be verified against dev data without touching the :8000 process.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The admin console could show what a conversation cost but had no path that starts from a user and nothing that records what they were doing. Both prior quota investigations (the
5801a350write:read audit, the compaction spiral) were hand-run DynamoDB sessions that ended in a named, computable classification. This PR adds the missing drill-down and turns those classifications into rules — without reading any conversation content.Spec:
docs/specs/admin-cost-drilldown.md. PR 1 of 3 (API); the SPA and the behavioral census follow as separate PRs.GET /admin/costs/users/{id}/sessions— a user's conversations, content-free (costKnown=falsemeans unrecorded, never $0; 20% of session rows have no cost aggregate).GET /admin/costs/sessions/{id}/profile— attachments (count/bytes, never names), per-call context trajectory, model mix, prefix-fingerprint churn, tool census (populated by PR 3), coverage flags, and 15 diagnosis rules with numeric evidence and the fix each investigation landed on.apis/shared/observability/content_policy.py(denylist + aliased projections) and a test that walks every admin cost response model — exactly one named exemption,TopSessionCost.title, kept by decision. A moto test seeds every kind of content and proves none returns.C#items includingcitations[].text; it now projects the twelve attributes it consumes.None— the user about to hit their quota is now visible from the table.Deploy notes
Verification
uv run python -m pytest tests/— 8,474 passed (92 new).🤖 Generated with Claude Code