Skip to main content

tracegc-crewai

tracegc-crewai is an official adapter package providing TraceGC graph-based context compaction for CrewAI agents, crews, and tasks.

Installation

pip install tracegc-crewai

Or install with test dependencies:

pip install tracegc-crewai[test]

Quick Start

1. Compact CrewAI Execution Steps via step_callback

Use TraceGCCrewCallback or create_step_callback() to record and compact step outputs during Crew execution:

from crewai import Agent, Crew, Task
from tracegc_crewai import create_step_callback

# Create a TraceGC step callback
step_cb = create_step_callback(
    prune_semantic=True,
    tracked_decision_keys={"database", "cache_backend"}
)

# Instantiate CrewAI Agent and Crew with step_callback
agent = Agent(
    role="Backend Architect",
    goal="Design scalable infrastructure",
    backstory="Senior system architect"
)

task = Task(
    description="Select storage engine and caching layer",
    expected_output="Final tech stack recommendation",
    agent=agent
)

crew = Crew(
    agents=[agent],
    tasks=[task],
    step_callback=step_cb
)

# Run crew...
# crew.kickoff()

# Compact accumulated step context
result = step_cb.compact()
print("Compacted messages:", len(result.messages))
print("Pruned receipts:", len(result.receipts))

2. Manual Context Compaction via compact_messages

If you manage task histories or step outputs directly:

from tracegc_crewai import compact_messages

step_history = [
    "Configured database=postgres",
    "Switched database=mongodb due to schema flexibility",
]

result = compact_messages(step_history, prune_semantic=True, tracked_decision_keys={"database"})
for msg in result.messages:
    print(msg["content"])
# Output retains only the active 'mongodb' decision and prunes the superseded 'postgres' choice.

Why TraceGC instead of CrewAI's Built-in Memory?

CrewAI provides a built-in memory subsystem (memory=True) featuring ShortTermMemory (using ChromaDB vector RAG), LongTermMemory, and EntityMemory.

While CrewAI's built-in memory excels at semantic retrieval (RAG) across tasks:

  • CrewAI Memory retrieves relevant facts by embedding similarity, but retains all past execution steps in raw history. It does not prune obsolete variables, superseded tech choices, or dead search branches.
  • TraceGC builds a deterministic dependency DAG over trace events. It mathematically prunes obsolete states, superseded configuration decisions, and abandoned branches while preserving exact provenance and recoverable receipts.

Using tracegc-crewai alongside CrewAI's memory ensures your agents run with minimal token context windows, zero obsolete state confusion, and full auditability.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tracegc_crewai-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracegc_crewai-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file tracegc_crewai-0.1.0.tar.gz.

File metadata

  • Download URL: tracegc_crewai-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for tracegc_crewai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 70c2361853262c3b8cb5a4921bcacdbe1029f98c48714e9f9d7e778005e04e61
MD5 40b4dbf2081aa9c127fedd5bf2cafdcf
BLAKE2b-256 ff4262295d53511ade84313308d91d1731a9fcd00a9ddfd0da3733f7dddb9b9a

See more details on using hashes here.

File details

Details for the file tracegc_crewai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tracegc_crewai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for tracegc_crewai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 161aceebe3fb4ab34636f35355fa62fadc2a35ae0d3cd8400480dc69bd697cc0
MD5 2ed3e69ba710d6afb834ad653c8fa9f5
BLAKE2b-256 777b2cee5733001f4d12204e1714f4b35155fad0f4365d71a782c1a32d8e8a64

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page