Chain of Thought Logs

Understand agent reasoning with detailed decision traces.

Overview

Chain of Thought (CoT) logs capture the complete reasoning process of your agents during negotiations and commerce operations. Every decision, consideration, and outcome is logged for transparency and debugging.

Viewing Logs

# View Chain of Thought logs for a session
$ hyperfold logs cot --session=sess_abc123
CHAIN OF THOUGHT: sess_abc123
Agent:              sales-negotiator
Customer:           cust_xyz (Gold tier)
Product:            AeroRun X2 Waterproof
Duration:           32.5s
Outcome:            conversion @ $155.00
REASONING TRACE
[10:15:00.100] CONTEXT LOADED
 Customer tier: gold (12 previous orders, $1,840 LTV)
 Product: AeroRun X2, MSRP $179.99, floor $135.00
 Inventory: 45 units (healthy)
 Competitor price: $169.99
[10:15:00.450] SEARCH RECEIVED
 Query: "waterproof running shoes for marathon"
 Semantic confidence: 0.94
 Matched products: 8
[10:15:01.200] INITIAL OFFER: $150.00
 Analysis: Offer is $29.99 below MSRP (16.7% discount)
 Floor check: $150 > $135 (above floor) ✓
 Decision: COUNTER_OFFER at $162.00 (10% discount)
[10:15:05.800] COUNTER OFFER: $155.00
 Margin at $155: 44.4% (acceptable)
 Decision: ACCEPT at $155.00
[10:15:06.100] BUNDLE SUGGESTION
 Complementary: Waterproof Running Socks ($29.99)
 Customer response: Declined
[10:15:32.500] CHECKOUT COMPLETE
 Final price: $155.00
 Discount given: 13.9%
 Margin achieved: 44.4%
 Negotiation rounds: 2

Log Structure

Each CoT entry contains the full context and reasoning for a decision:

{
  "session_id": "sess_abc123",
  "timestamp": "2025-01-20T10:15:01.200Z",
  "agent": "sales-negotiator",
  "event_type": "reasoning",
  "step": "price_decision",
  "input": {
    "offer_price": 150.00,
    "product_id": "prod_aero_x2",
    "customer_tier": "gold"
  },
  "context": {
    "product_floor": 135.00,
    "product_msrp": 179.99,
    "customer_ltv": 1840.00,
    "competitor_price": 169.99,
    "inventory_level": 45
  },
  "reasoning": {
    "thought": "Customer offer of $150 is 16.7% below MSRP...",
    "considerations": [
      "Gold tier typically expects 10-15% discount",
      "Offer above floor price - acceptable",
      "High customer LTV suggests retention priority"
    ],
    "decision": "counter_offer",
    "confidence": 0.85
  },
  "output": {
    "action": "counter_offer",
    "price": 162.00,
    "message": "I can offer you our Gold member price of $162..."
  },
  "metrics": {
    "llm_tokens": 847,
    "llm_latency_ms": 130,
    "total_latency_ms": 250
  }
}

Key Fields

FieldDescription
reasoning.thoughtNatural language reasoning from LLM
reasoning.considerationsFactors weighed in decision
reasoning.confidenceAgent's confidence in decision (0-1)
contextBusiness data available to agent
metricsPerformance metrics for the step

Analysis

# Analyze CoT logs for insights
$ hyperfold logs cot analyze --since=7d
COT ANALYSIS (7 days)
SESSIONS
  Total:              4,521
  Conversions:        1,492 (33.0%)
  Avg Rounds:         2.3
  Avg Duration:       28.4s
PRICE DECISIONS
  Accept (first):     12%
  Counter once:       45%
  Counter twice:      31%
  Reject:             12%
REASONING PATTERNS
  Customer tier cited: 78%
  Competitor price:    34%
  Inventory level:     23%
# Search for specific reasoning patterns
$ hyperfold logs cot search \
  --query="inventory" \
  --outcome=rejected \
  --since=24h
# Export for analysis
$ hyperfold logs cot export \
  --since=30d \
  --format=jsonl \
  --output=cot-logs-january.jsonl

Debugging

Use CoT logs to understand and improve failed negotiations:

# Debug a specific failed negotiation
$ hyperfold logs cot --session=sess_failed_001 --verbose
CHAIN OF THOUGHT: sess_failed_001
Agent:              sales-negotiator
Customer:           cust_new (Standard tier)
Outcome:            abandoned
[10:30:01.500] INITIAL OFFER: $200.00
 Analysis: Offer is $99.99 below MSRP (33.3% discount)
 Floor check: $200 < $250 (BELOW FLOOR) ✗
 Decision: REJECT
[10:30:15.000] SECOND OFFER: $220.00
 Analysis: Still below floor ($30 gap)
 Decision: REJECT
[10:30:45.000] SESSION TIMEOUT
 Customer did not respond for 30 seconds
DEBUG NOTES
 Customer was new (no loyalty benefits)
 Large gap between offer and floor (20%)
 No bundle or alternative suggested
RECOMMENDATIONS
  1. Consider offering entry-level alternative
  2. Suggest financing options for new customers
  3. Offer smaller discount for email signup
# Replay session with different parameters
$ hyperfold logs cot replay sess_failed_001 \
  --override-floor=220 \
  --dry-run
REPLAY SIMULATION (dry-run)
With floor=$220:
  - First offer ($200): Still rejected (below floor)
  - Second offer ($220): ACCEPTED
Simulated outcome: CONVERSION at $220