fix(mma): Add Tier 1 and Tier 2 token tracking from comms log
Task 2.2 of mma_pipeline_fix_20260301: _cb_plan_epic captures comms baseline before generate_tracks() and pushes mma_tier_usage['Tier 1'] update via custom_callback. _start_track_logic does same for generate_tickets() -> mma_tier_usage['Tier 2'].
This commit is contained in:
20
gui_2.py
20
gui_2.py
@@ -1990,8 +1990,21 @@ class App:
|
||||
proj = project_manager.load_project(self.active_project_path)
|
||||
flat = project_manager.flat_config(proj)
|
||||
file_items = aggregate.build_file_items(Path("."), flat.get("files", {}).get("paths", []))
|
||||
_t1_baseline = len(ai_client.get_comms_log())
|
||||
tracks = orchestrator_pm.generate_tracks(self.ui_epic_input, flat, file_items, history_summary=history)
|
||||
_t1_new = ai_client.get_comms_log()[_t1_baseline:]
|
||||
_t1_resp = [e for e in _t1_new if e.get("direction") == "IN" and e.get("kind") == "response"]
|
||||
_t1_in = sum(e.get("payload", {}).get("usage", {}).get("input_tokens", 0) for e in _t1_resp)
|
||||
_t1_out = sum(e.get("payload", {}).get("usage", {}).get("output_tokens", 0) for e in _t1_resp)
|
||||
def _push_t1_usage(i, o):
|
||||
self.mma_tier_usage["Tier 1"]["input"] += i
|
||||
self.mma_tier_usage["Tier 1"]["output"] += o
|
||||
with self._pending_gui_tasks_lock:
|
||||
self._pending_gui_tasks.append({
|
||||
"action": "custom_callback",
|
||||
"callback": _push_t1_usage,
|
||||
"args": [_t1_in, _t1_out]
|
||||
})
|
||||
self._pending_gui_tasks.append({
|
||||
"action": "handle_ai_response",
|
||||
"payload": {
|
||||
@@ -2097,7 +2110,14 @@ class App:
|
||||
skeletons = skeletons_str # Use provided skeletons
|
||||
|
||||
self.ai_status = "Phase 2: Calling Tech Lead..."
|
||||
_t2_baseline = len(ai_client.get_comms_log())
|
||||
raw_tickets = conductor_tech_lead.generate_tickets(goal, skeletons)
|
||||
_t2_new = ai_client.get_comms_log()[_t2_baseline:]
|
||||
_t2_resp = [e for e in _t2_new if e.get("direction") == "IN" and e.get("kind") == "response"]
|
||||
_t2_in = sum(e.get("payload", {}).get("usage", {}).get("input_tokens", 0) for e in _t2_resp)
|
||||
_t2_out = sum(e.get("payload", {}).get("usage", {}).get("output_tokens", 0) for e in _t2_resp)
|
||||
self.mma_tier_usage["Tier 2"]["input"] += _t2_in
|
||||
self.mma_tier_usage["Tier 2"]["output"] += _t2_out
|
||||
if not raw_tickets:
|
||||
self.ai_status = f"Error: No tickets generated for track: {title}"
|
||||
print(f"Warning: No tickets generated for track: {title}")
|
||||
|
||||
Reference in New Issue
Block a user