Skip to content

feat(callbacks/langfuse): optional OpenAI-shaped tools on generation … - #943

Open
SunflowersFacingNight wants to merge 3 commits into
cloudwego:mainfrom
SunflowersFacingNight:feat/langfuse-report-tool-definitions
Open

feat(callbacks/langfuse): optional OpenAI-shaped tools on generation …#943
SunflowersFacingNight wants to merge 3 commits into
cloudwego:mainfrom
SunflowersFacingNight:feat/langfuse-report-tool-definitions

Conversation

@SunflowersFacingNight

Copy link
Copy Markdown

Summary

  • Add optional Config.ReportTools (default false).
  • When enabled and tools are bound, serialize generation Input as OpenAI chat.request JSON:
    {messages, tools[{type:function,function:{...}}], tool_choice} for Langfuse Playground extractTools.
  • Skip InMessages on that path so the acl consumer does not overwrite Input with messages-only JSON.
  • Keep modelParameters as *model.Config (sampling only).

Test plan

  • [✓] Unit: with ReportTools: true, generation Input contains tools / tool_choice and InMessages is empty
  • [✓] Default ReportTools: false is unchanged (existing generation tests cover the InMessages path)
  • [✓] Verified in our internal test environment:
    • With ReportTools enabled, Langfuse generation Input is OpenAI chat.request–shaped and includes bound tool definitions
    • Playground / extractTools can pick up tools from the reported Input
    • With ReportTools disabled, reporting matches previous behavior

Uploading 20260806-220546.jpeg…

…Input

Add Config.ReportTools (default false). When enabled and tools are bound,
serialize generation Input as OpenAI chat.request JSON:
{messages, tools[{type:function,function:{...}}], tool_choice}.

Playground extractTools reads input.tools; skip InMessages so the acl
consumer does not overwrite Input. modelParameters stay *model.Config.
@CLAassistant

CLAassistant commented Aug 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread callbacks/langfuse/langfuse.go Outdated
Comment thread callbacks/langfuse/langfuse_test.go Outdated
Only set OpenAI-shaped Input when at least one non-nil tool converts;
all-nil or empty tools keep InMessages for the ACL media path.

@shentongmartin shentongmartin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants