Skip to content

fix report stats: populate task counts from kanban#340

Draft
deepmasq wants to merge 2 commits intomainfrom
feat/karen-plan-8-report-stats
Draft

fix report stats: populate task counts from kanban#340
deepmasq wants to merge 2 commits intomainfrom
feat/karen-plan-8-report-stats

Conversation

@deepmasq
Copy link
Copy Markdown
Contributor

Summary

  • section02-tasks in daily/weekly reports was always zeros despite kanban data being fetched
  • Wire done_tasks and by_code (already computed for section04) into section02-tasks
  • Update return message: stop telling model to manually fill pre-filled stats

Test plan

  • Run karen_report(report_type='daily') on staging with tasks in kanban
  • Verify section02-tasks counts match actual done tasks
  • Verify section04-resolution-summary still populated correctly

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread flexus_simple_bots/karen/karen_bot.py Outdated
@@ -361,11 +361,11 @@ async def handle_report(
"refund_amount": refund_amount,
},
"section02-tasks": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't section 2 and section 4 the same? I guess one needs to be removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — both sections collapsed. The two sections shared the same resolution-code source rows; only sentiment_notes was unique. Now there's just section01-crm and section02-notes (free-text including sentiment_notes and task_resolution_summary). See dafa598.

Comment thread flexus_simple_bots/karen/karen_bot.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oleg's comment

# XXX bad idea:
# - there are infinite tasks here
# - model already asks kanban about all the counters

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed per Oleg — the bot_get_all_tasks call is gone, along with section02-tasks and section04-resolution-summary. Karen has flexus_kanban_advanced, so the model can ask kanban for resolution counters directly when filling in the report. See dafa598.

@deepmasq
Copy link
Copy Markdown
Contributor Author

Reviewed @humbertoyusta's comments — section 2 (task counts) and section 4 (resolution-by-code summary) draw from the same source rows but answer different questions, so I left them split. Happy to consolidate if you'd rather see one combined section. Oleg's XXX about infinite tasks is a bigger refactor, out of scope here. Ready to merge from my side.

deepmasq pushed a commit that referenced this pull request Apr 27, 2026
- drop total_cost_usd and avg_cost_per_conversation USD fields from
  section05-costs; coins are the source of truth (Humberto comment)
- rename avg field to avg_coins_per_conversation, integer division
- revert section02-tasks fix and instruction text update — that work
  belongs to #340 (Humberto comment)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tools

Sections 2 (task counts) and 4 (resolution outcomes) drew from the same
resolution-code aggregation, only sentiment_notes was unique. Bot already
has flexus_kanban_advanced — let the model query counters directly instead
of pre-fetching every task on every report (Oleg's "infinite tasks").

Schema collapses to two sections: section01-crm (pre-filled) and
section02-notes (free-text, includes sentiment_notes and a new
task_resolution_summary the model fills from kanban).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@deepmasq
Copy link
Copy Markdown
Contributor Author

@humbertoyusta @olegklimov — addressed both review comments in dafa598.

What changed: deleted the bot_get_all_tasks fetch + by_code aggregation, dropped section02-tasks and section04-resolution-summary entirely. Schema now has just two sections — section01-crm (CRM/order numbers, pre-filled by ERP queries) and section02-notes (free-text including sentiment_notes and task_resolution_summary). The model uses flexus_kanban_advanced(op="status") to read counters when it fills the notes.

Why this resolves both comments:

  • (1) sections 2 & 4 shared the same resolution-code source — they were genuinely redundant. Collapsed.
  • (2) Oleg's "infinite tasks / model already asks kanban" — the inlined fetch is gone. Karen's default expert already has flexus_kanban_advanced, so the model gets counters on demand without the unbounded query.

Net: -39 lines.

"refund_amount": refund_amount,
},
"section02-tasks": {
"tasks_completed": 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we delete the zeroes does the model knows where to store the counts?

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.

2 participants