Skip to content

fix: emit llm.invocation_parameters on haystack generator spans - #4465

Open
feiiiiii5 wants to merge 1 commit into
Arize-ai:mainfrom
feiiiiii5:feiiiiii5/D233
Open

feiiiiii5 wants to merge 1 commit into
Arize-ai:mainfrom
feiiiiii5:feiiiiii5/D233

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Fixes #4451

Haystack LLM/generator spans never carry llm.invocation_parameters, so generation_kwargs such as temperature=0.0 and max_tokens=50 are invisible in traces.

Root cause

The GENERATOR branch of _set_component_runner_request_attributes() sets span kind and input attributes but never emits LLM_INVOCATION_PARAMETERS, even though the constant is bound in the module. The embedder branch already emits its invocation parameters.

Fix

Added _get_llm_invocation_parameters() which merges component-level and per-run generation_kwargs (per-run wins) and serializes with safe_json_dumps. Values are preserved by key presence, not truthiness, so 0.0 survives. Wired into the GENERATOR branch.

Verification

  • Base-red: targeted test test_output_messages_keep_content_without_finish_reason failed with KeyError: 'llm.invocation_parameters', exit 1.
  • With fix: 3 targeted tests passed (including falsey value and per-run override); full instrumentation suite 64 passed / 5 skipped / 1 pre-existing environment-only entrypoint failure.
  • ruff format --check: clean. ruff check: only two pre-existing I001 warnings, identical on base. mypy: one pre-existing no-any-return unrelated to this change.

Live provider paths not exercised; VCR cassettes only. Pinned CI haystack version not reproduced.

This branch has not been deployed

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[bug]: haystack LLM spans have no llm.invocation_parameters

1 participant