Skip to content

Conversation

@oerc-s
Copy link

@oerc-s oerc-s commented Dec 27, 2025

Summary

Adds optional PrimordiaMeter for tracking crew execution costs with machine-readable receipts.

Usage

from crewai import Crew, Agent, Task
from crewai.utilities import PrimordiaMeter

meter = PrimordiaMeter(agent_id="crew-alpha")

# Record task completions
meter.record_task("research", "researcher_agent", tokens_used=1500, model="gpt-4")

# After crew.kickoff()
print(f"Crew cost: ${meter.get_crew_cost():.4f}")
print(f"Receipts: {len(meter.get_receipts())}")

Features

  • Per-task cost tracking
  • Shadow mode (local only, no network calls)
  • MSR (Machine Settlement Receipt) format for settlement compatibility
  • Zero blocking, zero risk

No new dependencies

Uses only Python stdlib.

Kernel

Live at https://clearing.kaledge.app


Note

Adds local metering to track crew execution costs and emit machine-readable receipts.

  • Introduces PrimordiaMeter in crewai/utilities/primordia.py to record tasks as MSR receipts with hashed IDs
  • Calculates cost via simple per-token pricing by model (gpt-4, claude, default) and provides get_crew_cost()
  • Exposes get_receipts() for settlement; operates in shadow mode (no network), storing receipts in-memory

Written by Cursor Bugbot for commit 45e0646. This will update automatically on new commits. Configure here.

Adds optional PrimordiaMeter for tracking crew execution costs with machine-readable receipts.

Features:
- Per-task cost tracking
- Shadow mode (local only)
- MSR format for settlement compatibility
- Zero blocking

No new dependencies.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

"task": task_name,
"agent": agent_name,
**(metadata or {})
}
Copy link

Choose a reason for hiding this comment

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

User metadata can silently override critical receipt fields

The metadata dict is unpacked after framework, task, and agent are set, meaning user-provided metadata containing these keys will silently override the values from the explicit task_name and agent_name parameters. For receipts used in billing/settlement, this could lead to incorrect data. If a user accidentally reuses a dict that contains a task or agent key, the receipt would have wrong identifiers despite passing correct explicit parameters.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant