Skip to content

routing: make system prompts follow answer targets #496

Description

@afourniernv

Linear: SWITCH-1253

Problem

A client calls a Switchyard route without knowing which upstream model will answer. Those models may need different standing system instructions.

Today this is only configurable through Stage and Composite route fields such as efficient_system_prompt and capable_system_prompt. Other routers do not have the same configuration surface.

Fallback also matters. If a route selects fast and that target fails, the request sent to capable must receive the capable prompt. It cannot reuse a request already prepared for fast.

Proposed interface

Allow the prompt to be configured on a target:

[targets.fast]
id = "meta/llama-small"
llm_client = "together"
system_prompt = "Be concise."

[targets.capable]
id = "meta/llama-large"
llm_client = "together"
system_prompt = "Reason carefully."

[routes.agent]
id = "switchyard/agent"
type = "stage_router"
efficient_target = "fast"
capable_target = "capable"

The prompt should follow the answer target rather than the router type. Judge, classifier, and reviewer calls should remain unchanged.

Implementation

  • Translation owns the model and prompt mutation for one request.
  • libsy remains provider-neutral and does not carry answer-call or request-preparation state.
  • libsy-llm-client distinguishes routing dependencies from completion candidates and prepares each selected or fallback candidate immediately before it is called.
  • The native runner builds the effective prompt map from [targets.*].system_prompt.

This keeps provider request mutation out of libsy and prevents one candidate's prompt from leaking into a fallback.

Compatibility

  • Existing configuration without target prompts behaves as before.
  • Native Stage and Composite configuration must move capable_system_prompt and efficient_system_prompt to [targets.*].system_prompt.
  • Direct libsy and Python Stage prompt configuration remain unchanged.
  • Routing decisions, retry behavior, and fallback order do not change.

Pull requests

Done when

  • Every built-in client-visible answer path uses the selected target's prompt.
  • Each fallback is prepared independently.
  • Existing caller instructions are preserved after the target prompt.
  • Judge, classifier, and reviewer calls remain unprompted.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions