Repository navigation
Conversation
…t token Adds an `invocation` block to LLM and question-classifier node data, a sibling of `model`, holding per-node policy about how a model is called rather than what is asked of it. Its only setting today is `first_token_timeout_ms`. It exists because the host has nowhere else to put a first-token timeout. `ModelConfig.completion_params` is forwarded to model providers verbatim, so a host-internal setting there needs a defensive pop at every consumer, one forgotten pop sends an unknown argument to a provider, and the value lands in exported DSL next to `temperature` as if the provider understood it. The block exposes the value in seconds as `first_token_timeout`, which is the unit every hop below graphon works in; milliseconds are the DSL and UI unit only, and this is the single place the conversion happens. The field carries no alias, because `Node.validate_node_data` dumps by name on every construction and an alias would silently drop the value there. The parameter extractor deliberately has no block. It invokes with `stream=False`, where the single result arrives once generation has finished, so a first-token timeout would quietly become a total-generation timeout. graphon carries the value and enforces nothing; the host reads it off the node data. No argument is added to `LLMProtocol` -- that would hand every adapter that cannot honour it one more argument with no effect, which is the shape TD-06 already tracks, and it would make any host lacking the keyword fail on every LLM call. PR #212 took that route; keeping graphon a carrier means no host has to move first. Separately, `LLMNode` now publishes the time to first token it already measures into `LLMUsage`, under a new `TIME_TO_FIRST_TOKEN` metadata key, so an operator has a number to base a timeout on. A run that streamed no content omits the key rather than recording a null; a genuine 0.0 is still published. Both changes are additive and optional. Workflows saved before this deserialize unchanged. Closes #293
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
!Related Issue
Closes #293
Summary
Adds an
invocationblock to LLM-family node data, and publishes the time-to-first-token the LLM node already measures as node execution metadata.invocationis a sibling ofmodel, not part ofcompletion_params. A per-node first-token budget is being threaded through the Dify plugin chain, andcompletion_paramsis the wrong home for it: that dictionary is forwarded to model providers verbatim, so every consumer needs a defensivepop, and the value shows up in exported DSL next totemperatureas if the provider understood it.first_token_timeout_msis an optional positive integer; absent means no budget. The block exposes it asfirst_token_timeoutin seconds, which is the unit every hop below graphon works in — milliseconds are the DSL and UI unit only, and this is the single place the conversion happens.LLMNodeDataandQuestionClassifierNodeDataget the block.ParameterExtractorNodeDatadeliberately does not: that node invokes withstream=False, where a single result arrives only once generation has finished, so a first-token budget there would quietly become a total-generation budget.graphon carries the value and enforces nothing. It is read off the node data by the host adapter, which owns the transport. In particular this adds no parameter to
LLMProtocol— that would hand every adapter that cannot honour it one more argument with no effect, which is the shape TD-06 already tracks. Closed PR #212 attempted exactly that and its own compatibility table shows the cost: any implementation without the keyword and without**kwargsraisesTypeErroron every LLM call, forcing an ordering constraint on the host's pin bump. Keeping graphon a carrier removes that constraint.The second change is smaller.
LLMNodealready measures TTFT intoLLMUsage.time_to_first_tokenbut never surfaced it per node, so an operator had no number to base a budget on. It now writesWorkflowNodeExecutionMetadataKey.TIME_TO_FIRST_TOKENalongside the existing token and price keys, and omits the key entirely when no content streamed rather than recording a null.Both changes are additive and optional. Workflows saved before this deserialize unchanged, and a host that ignores
invocationbehaves exactly as it does today.Checklist
!