MCPcopy
hub / github.com/phuryn/claude-usage / _make_assistant_record

Function _make_assistant_record

tests/test_scanner.py:40–64  ·  view source on GitHub ↗
(session_id="sess-1", model="claude-sonnet-4-6",
                           input_tokens=100, output_tokens=50,
                           cache_read=10, cache_creation=5,
                           timestamp="2026-04-08T10:00:00Z",
                           cwd="/home/user/project",
                           message_id="")

Source from the content-addressed store, hash-verified

38
39
40def _make_assistant_record(session_id="sess-1", model="claude-sonnet-4-6",
41 input_tokens=100, output_tokens=50,
42 cache_read=10, cache_creation=5,
43 timestamp="2026-04-08T10:00:00Z",
44 cwd="/home/user/project",
45 message_id=""):
46 msg = {
47 "model": model,
48 "usage": {
49 "input_tokens": input_tokens,
50 "output_tokens": output_tokens,
51 "cache_read_input_tokens": cache_read,
52 "cache_creation_input_tokens": cache_creation,
53 },
54 "content": [],
55 }
56 if message_id:
57 msg["id"] = message_id
58 return json.dumps({
59 "type": "assistant",
60 "sessionId": session_id,
61 "timestamp": timestamp,
62 "cwd": cwd,
63 "message": msg,
64 })
65
66
67def _make_user_record(session_id="sess-1", timestamp="2026-04-08T09:59:00Z",

Calls

no outgoing calls

Tested by

no test coverage detected