Skip to content

feat: trace payloads without truncation - #32

Merged
hassiebp merged 1 commit into
mainfrom
feat/no-payload-truncation
Sep 14, 2026
Merged

hassiebp merged 1 commit into
mainfrom
feat/no-payload-truncation

Conversation

@milanagm

@milanagm milanagm commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Closes LFE-16188

Problem

Every captured payload was cut at PI_LANGFUSE_MAX_CHARS (default 20000), so a long prompt, a long answer or a large tool result reached Langfuse shortened, and the trace no longer showed what actually happened.

What this does

Removes PI_LANGFUSE_MAX_CHARS, truncateText() and TruncationMeta, so these all go out at full length:

Value Observation field
event.prompt turn root input.content, and the first generation's input
state.lastAssistantText turn root output.content
assistant text on message_end generation output.content
tool arguments Tool: span input
tool result Tool: span output
compaction summary Compaction output.content
branch summary Branch Summary output.content

Also gone:

  • The metadata that only existed to report a cut: user_text_meta, assistant_text_meta (root and generation), args_meta, output_meta, summary_meta (compaction and branch summary).
  • A second, harder limit that was not configurable: outText.slice(0, 4000) on pendingToolResults, the tool results that appear as the next generation's input. They were cut twice — first to 20000, then to 4000.
  • The node:crypto import, which only served the truncation marker's sha256.

Tests

pnpm test: 60 passing (the two truncateText unit tests went with the function), and tsc --noEmit clean. Verified against all three CI matrix versions — pi 0.83.0, 0.84.3 and 0.85.0.

@milanagm
milanagm requested a review from hassiebp September 10, 2026 21:46
milanagm added a commit that referenced this pull request Sep 10, 2026
#31 landed the system prompt while this branch was open, and both changes
rewrite the generation input. The resolution composes them: state.systemPrompt
keeps its place at the front, the history takes the place of baseInput, and the
spread now also accepts an array, since the history is one.

Both new handlers are kept — pi.on("context") and pi.on("agent_start") are
independent of each other.

The history also stops borrowing MAX_CHARS. It marks data URIs but adds no
length cap of its own, so this branch neither reads nor removes any part of the
truncation machinery. #32 can therefore land before or after this PR.

#31's generation-input test asserted the delta shape (exactly one message behind
the system prompt). It now asserts the conversation, which is what this branch
changes.
@hassiebp
hassiebp merged commit 9839192 into main Sep 14, 2026
13 checks passed
@hassiebp
hassiebp deleted the feat/no-payload-truncation branch September 14, 2026 15:24
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