Skip to content

Stop dropping long-session spans and typed workflow agents - #3

Merged
miguel-border merged 3 commits into
mainfrom
feat/history-opt-out
Oct 12, 2026
Merged

miguel-border merged 3 commits into
mainfrom
feat/history-opt-out

Conversation

@miguel-border

Copy link
Copy Markdown
Collaborator

Problem

Since upstream v1.2 (langfuse#80), every generation's input carries the conversation so far. On a long session this grows quadratically, because every LLM call repeats every earlier message.

What breaks:

  • A single span batch can exceed the OTLP exporter's 64 MiB max_request_size.
  • When it does, the exporter drops the whole batch.
  • The only trace of the loss is a stderr line: nothing in the hook log, nothing on the server.

Measured re-sending one 165-turn session with v1.2.1:

  • 51 batches dropped, each between 67 MB and 425 MB.
  • Langfuse ended with 147 of 165 traces.

Change

  • New setting CC_LANGFUSE_CAPTURE_HISTORY: an env var and a plugin userConfig option.
  • Default true: upstream behaviour is unchanged.
  • Set to false: the hook skips building the session history, so each generation carries only its own new input, as before v1.2.

Tests

  • New: test_history_opt_out_sends_only_each_turns_own_input.
  • Planted control: when the code ignores the setting, the new test fails.
  • Suite: 286 passed, 1 failed. The failure is test_state_lock_contention, which also fails on a clean upstream/main.

Follow-up for TopCode

Set CC_LANGFUSE_CAPTURE_HISTORY=false in the repo's .claude/settings.json env. Our sessions run to hundreds of turns, so history makes every LLM call repeat the whole session.

🤖 Generated with Claude Code

Miguel Pereira and others added 2 commits October 12, 2026 17:17
Since v1.2 every generation's input carries the whole conversation so far. On a
long session that is quadratic: each LLM call repeats every earlier message,
and one span batch can exceed the OTLP exporter's 64 MiB request limit, which
then drops the entire batch with only a stderr line. Measured re-sending one
165-turn session: 51 batches of 67-425 MB dropped.

CC_LANGFUSE_CAPTURE_HISTORY (default true, upstream behaviour unchanged) set to
false skips building the session history, so each generation carries its own
new input only, as before v1.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_workflow_agents_in_run_dir kept only metas whose agentType was
"workflow-subagent", which is what an untyped spawn records. A workflow script
that names a type (agent(..., {agentType: 'round-writer'})) records that type
instead, so every such agent was dropped and the Workflow tool span came out
with no children. Measured on one session: 0 of ~1,000 round agents traced,
$990 of cost missing.

A workflow agent is now identified by living in the run directory without a
toolUseId (classic subagent) or taskKind (teammate), whatever its type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@miguel-border miguel-border changed the title Add CC_LANGFUSE_CAPTURE_HISTORY to stop quadratic generation inputs Stop dropping long-session spans and typed workflow agents Oct 12, 2026
… limit

The SDK default of 512 spans per OTLP request, with spans carrying up to
MAX_CHARS of input and output each, reached the exporter's 64 MiB
max_request_size; an over-limit batch is dropped whole (measured: five 67 MB
batches dropped re-sending one session with history off). LANGFUSE_FLUSH_AT
now defaults to 128 unless the user set it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@miguel-border
miguel-border merged commit ad31424 into main Oct 12, 2026
3 of 5 checks passed
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.

1 participant