Skip to content

[Enhancement]: Account for LLM calls made inside native routing plugins #1002

Description

@afourniernv

Affected area

  • Native plugins
  • Observability and ATIF

Problem

A native routing plugin can make judge or classifier calls before returning one answer. Relay
prices the answer, but those internal calls are not part of the parent call's cost summary.

Relay can already price the internal calls if the plugin emits each one as an LLM scope. I tested
that on current main: ATIF correctly summed a $0.11 routing call and a $0.00045 answer to
$0.11045. The problem is that ATIF also turned both calls into normal source="agent" steps.
The routing call was never visible to the agent, so it should not appear as another agent message.

The other existing paths do not close the gap:

  • A metric mark avoids the extra ATIF step, but Relay does not price it or include it in ATIF totals.
  • Calling LlmNext::call twice reaches the provider twice, but Relay still emits one LLM start and
    end and prices only the returned response.
  • Optimization contributions from request intercepts arrive before the routing calls have run.

Desired behavior

Provide a supported way for a native execution plugin to report internal LLM work so Relay can:

  • price it with the existing pricing catalog;
  • keep answer cost and internal-call cost separate;
  • include both in an observed total when usage and pricing are available; and
  • keep internal calls out of the ATIF conversation while retaining their cost in aggregate metrics.

If usage or pricing is missing, the total should remain partial rather than treating the call as
free. Calculating a savings baseline is separate from this issue.

Switchyard still owns emitting the model, provider, usage, and timing for its calls. This issue is
only about the Relay surface and export behavior needed to account for them.

Related: Relay #389,
Relay #814,
Switchyard #528, and
Switchyard #629.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Improvementimprovement to existing functionalityNeeds TriageIssue needs Triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions