Skip to content

feat(llm): expose model_provider and model_name as node outputs - #226

Open
dparkmit24 wants to merge 1 commit into
langgenius:mainfrom
dparkmit24:llm-node-model-identity-outputs
Open

feat(llm): expose model_provider and model_name as node outputs#226
dparkmit24 wants to merge 1 commit into
langgenius:mainfrom
dparkmit24:llm-node-model-identity-outputs

Conversation

@dparkmit24

@dparkmit24 dparkmit24 commented Jul 20, 2026

Copy link
Copy Markdown

Important

  1. Make sure you have read our contribution guidelines
  2. Search existing issues and pull requests to confirm this change is not a duplicate
  3. Open or identify the issue this pull request resolves or advances
  4. Use a Conventional Commits title for this pull request, and mark breaking changes with !
  5. Remember that the pull request title will become the squash merge commit message
  6. If CLA Assistant prompts you, sign CLA.md in the pull request conversation

Related Issue

Advances #225

Summary

Adds two top-level string outputs to the LLM node — model_provider and model_name — so downstream nodes can reference the generation's model identity.

Use case. I'm building a five-model comparison workflow: five parallel LLM nodes feed a judge node and an Answer node, and each response needs to be labelled with the model that produced it. There's no output variable carrying the model identity today, so the labels have to be hardcoded as literal text in the Answer node — which silently desyncs the moment a node's model is swapped. These outputs let the workflow label each response from the node's actual configuration.

Implementation. The pair is sourced from the model instance already in scope at output assembly — the same values build_model_identity_inputs already exposes to node inputs, reusing that naming convention rather than inventing model/provider. Falsy values coerce to empty strings so the outputs always carry both keys without raising. self._model_instance is typed non-optional and is already dereferenced one line earlier, so this introduces no new failure mode.

Design choices — proposals, open to change

  1. Top-level, not nested under usage. usage is metering data (tokens, prices, latency); model identity is a different kind of thing, and nesting would mean {{#LLM.usage.model_name#}} for the common case, with usage typed as an object making sub-field selection clumsier in the picker. That said, usage is a legitimate alternative — happy to move it there if you'd prefer.
  2. Two separate strings, not one combined identifier. ModelConfig already stores provider and name separately and there's no precomputed combined form. Splitting also avoids the ambiguity of a bare model name, since two providers can serve same-named models. Happy to collapse to a single output if you'd rather keep the surface smaller.
  3. Names mirror the existing inputs. Slightly more verbose than model, but consistent with what the codebase already calls these values.

Companion frontend change

This alone won't surface the outputs in the variable picker — that list is hardcoded in langgenius/dify's frontend (LLM_OUTPUT_STRUCT, the node's Output panel, and i18n). I'll open a companion PR there once this lands and a graphon release ships. Happy to do that whenever you're ready.

Tests

Added to tests/nodes/llm/test_node.py, mirroring the existing test_run_emits_model_identity_in_node_result_inputs:

  • an end-to-end test asserting both outputs carry the expected values
  • a unit test for the empty-string fallback

uv run pytest tests/nodes/llm/test_node.py → 51 passed.

Note: a full uv sync fails on ARM macOS building llvmlite (transitive via unstructurednumba), which is unrelated to the LLM node path. I ran the targeted suite with those packages skipped; CI uses Linux wheels, so this doesn't affect the build.

Checklist

  • This pull request links the issue it resolves or advances
  • This pull request title follows Conventional Commits, and any breaking change is marked with !
  • If CLA Assistant prompted me, I signed CLA.md in the pull request conversation

Implemented with AI assistance (Claude) using a two-agent workflow, and reviewed by me before submitting.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels Jul 20, 2026
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

All contributors on this pull request have signed the CLA.
Posted by the CLA Assistant Lite bot.

@dparkmit24

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Add model_provider and model_name to the LLM node's run outputs so
downstream nodes can reference the generation's model identity (e.g. to
label each response in a multi-model comparison workflow) instead of
hardcoding model names as literal text.

The pair is sourced from the model instance already in scope at output
assembly - the same values build_model_identity_inputs already exposes
to node inputs - reusing that naming convention. Falsy values coerce to
empty strings so the outputs always carry both keys without raising.
@dparkmit24
dparkmit24 force-pushed the llm-node-model-identity-outputs branch from 9f64d1b to c46ac3b Compare July 20, 2026 15:50
@dparkmit24

Copy link
Copy Markdown
Author

recheck

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

Labels

enhancement New feature or request size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant