Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/tla/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Sources: [module structure](https://learning.tlapl.us/intro/module-structure/) a
## Run TLC

1. Download `tla2tools.jar` to a folder outside the repo. Do not commit it.
2. Run: `java -XX:+UseParallelGC -cp <jar> tlc2.TLC -metadir <folder outside the repo> -config Spec.Variant.cfg Spec.tla`. Without `-metadir`, TLC writes a `states` folder here.
2. Run: `java -XX:+UseParallelGC -cp <jar> tlc2.TLC -metadir <folder outside the repo> -config Spec.Variant.cfg Spec.tla`. Without `-metadir`, TLC writes a `states` folder here. If `SpecMC.tla` exists, give it instead of `Spec.tla`. `check.sh` does this.
3. If the system can end, add `CHECK_DEADLOCK FALSE` to the config. Without it, TLC reports the end as a deadlock.
4. Pick the smallest constants that show the interaction. Two links are enough for interleaving.

Expand Down
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.AllCalls.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
SignedCall <- EveryCall
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.DropStored.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
OriginMatches <- NeverMatch
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode SignatureDelivered
10 changes: 10 additions & 0 deletions docs/architecture/tla/ThoughtSignature.Legacy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
SignatureModelNames <- OldNames
Flagged <- NoFlag
MarkerFallback <- NoMarkerFallback
Captured <- CapturedNative
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.MarkerAlways.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
MarkerFallback <- MarkerAlways
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.ModelOnly.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
Origin <- ModelOrigin
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.NameOnly.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
Flagged <- NoFlag
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.NativeLeak.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
NativeUses <- NativeAny
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.NoMarker.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
MarkerFallback <- NoMarkerFallback
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.NoOrigin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
OriginMatches <- AnyOrigin
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.NoReset.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
Captured <- CapturedKept
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.OldRegex.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
SignatureModelNames <- OldNames
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode
7 changes: 7 additions & 0 deletions docs/architecture/tla/ThoughtSignature.Unlisted.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
Listed <- AnyListed
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall
6 changes: 6 additions & 0 deletions docs/architecture/tla/ThoughtSignature.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SPECIFICATION Spec
CHECK_DEADLOCK FALSE
CONSTANTS
MaxTurns = 2
CONSTRAINT Bounded
INVARIANTS TypeOK NoRejectedCall NoCorruptIdDecode SignatureDelivered
171 changes: 171 additions & 0 deletions docs/architecture/tla/ThoughtSignature.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---- MODULE ThoughtSignature ----
\* Models the Gemini thought signature round trip through the task history (PR 2119).
\* Source: LiteLLMHandler.createMessage reads provider_specific_fields (readThoughtSignature).
\* prepareAssistantMessage stores it with getThoughtSignatureOrigin. Native Gemini stores it without an origin.
\* Sink: applyThoughtSignatures (LiteLLM) and convertAnthropicContentToGemini (native) on the next request.
\* Config value: requiresThoughtSignatures. getLiteLLMModels sets it from litellm_params.model.
\* Its reader is createMessage. The default (model not in the catalog) falls back to the model id.
\* Failure: a backend rejects a tool call in the history. Invariant: NoRejectedCall.
\* Gemini rejects a signature from another backend or step, and a signature on a later parallel call.
\* Gemini rejects a first call with no signature. LiteLLM decodes a __thought__ id when the call has no field.
\* A backend that does not run Gemini can reject the field (BerriAI/litellm#19739).
\* Failure 2: LiteLLM decodes a sanitized __thought__ id, even for a model missing from the catalog.
\* Invariant 2: NoCorruptIdDecode. Round 2 found it: with the flag, only an unlisted model needs the marker.
\* Failure 3: a LiteLLM backend does not get back the signature it minted. Invariant 3: SignatureDelivered.
\* Round 1 expected: Fixed holds. Legacy fails on the alias backend. Each sabotage fails. Result: as expected.
\* Round 1 finding: an alias got no bypass for an unsigned call, for example a call from Claude.
\* Round 2 adds the catalog flag, Gemini 4 (g4) and an alias routed to Claude (other).
\* Round 2 expected: Fixed holds for a listed model. NameOnly fails on the alias. OldRegex fails on g4.
\* Unlisted fails on the alias: a model missing from the catalog has only its name. Result: as expected.
\* Round 3 adds the rejection by a non-Gemini backend. Expected: MarkerAlways (round 2 code) fails on other.
\* Fixed holds: for a listed model, the catalog flag alone decides. Result: as expected.
\* Round 3 also drops the alias name from the flag and derives the stored origin. No verdict changed.
\* Round 4 adds SignatureDelivered. The bypass is always accepted, so NoRejectedCall passes a lost signature.
\* Round 4 expected: DropStored passes NoRejectedCall and NoCorruptIdDecode and fails SignatureDelivered. Result: as expected.
\* Variants are in ThoughtSignatureMC.tla. Each one replaces one or more operators of this module.
\* Run: java -cp <jar> tlc2.TLC -metadir <dir> -config <ThoughtSignature[.Variant].cfg> ThoughtSignatureMC.tla
\* TLC checks every next backend, so one turn is enough for most failures.
\* | Config | Variant | Verdict |
\* | ThoughtSignature.cfg | the PR code, listed model | holds (507 states) |
\* | ThoughtSignature.Legacy.cfg | code before the PR (bypass on name only) | fails after 1 turn |
\* | ThoughtSignature.NameOnly.cfg | round 1 code: no catalog flag | fails after 1 turn |
\* | ThoughtSignature.MarkerAlways.cfg | round 2 code: marker fallback when listed | fails after 1 turn |
\* | ThoughtSignature.OldRegex.cfg | matcher of Gemini 3 and 2.5 only | fails after 1 turn |
\* | ThoughtSignature.Unlisted.cfg | the PR code, model missing from catalog | fails after 1 turn |
\* | ThoughtSignature.ModelOnly.cfg | origin ignores litellmBaseUrl | fails after 1 turn |
\* | ThoughtSignature.NoOrigin.cfg | no origin check | fails after 1 turn |
\* | ThoughtSignature.AllCalls.cfg | signature on every parallel call | fails after 1 turn |
\* | ThoughtSignature.NoMarker.cfg | bypass on the model name only | fails after 1 turn |
\* | ThoughtSignature.NoReset.cfg | lastThoughtSignature kept across requests | fails after 2 turns |
\* | ThoughtSignature.NativeLeak.cfg | native Gemini reads a LiteLLM signature | fails after 1 turn |
\* | ThoughtSignature.DropStored.cfg | stored signature never sent (bypass only) | fails after 1 turn |
\* Fixed also holds at MaxTurns 3 (11,155 states).
\* Replay of Legacy: issue 2064. The reporter used a Gemini model behind a custom gateway alias.
\* Residual (Unlisted): an alias missing from the catalog gets no bypass for a call from another model.
\* Residual (Unlisted): a non-Gemini model missing from the catalog gets the field for a __thought__ id.
\* Oracles: Gemini validity of each signature, isLiteLLMThoughtSignatureModel, the origin hash (no collisions).
\* Oracle: the routed model of a Gemini alias matches isLiteLLMThoughtSignatureModel.
\* Not modeled: R1 format, id normalization, the native position of the signature (it is on every call).
\* Property test: lite-llm.spec.ts, "never sends a call that a backend rejects" (220 cases).
\* It checks NoRejectedCall for a listed model, and NoCorruptIdDecode and SignatureDelivered for both.
\* Sabotage of the code: NameOnly, MarkerAlways, NoMarker, NoOrigin, ModelOnly, AllCalls and DropStored fail it.
\* NoReset passes it. NoReset needs two requests on one handler. The test "resets it per request" covers that.
\* OldRegex passes it. The test sets the catalog flag. The fetcher and matcher tests fail on OldRegex.
\* Cost: TLC runs each config in under 2 seconds. Agent time is not measured.
\* Review: 2 covered, 1 added, 5 gap, 2 on the spec files (PR 2119). See the list below Rejected.
\* The first version came after the code and the reviews. It is not an independent first pass.

EXTENDS Naturals, Sequences

VARIABLE history \* One assistant message per turn. Each message has the fields of Message.

\* g1 and g2: one Gemini model on two gateways. g4: a Gemini 4 model id.
\* alias: a Gemini model under a LiteLLM alias. other: an alias routed to Claude.
Backends == {"g1", "g2", "g4", "alias", "other", "native"}
Url(b) == IF b = "g2" THEN "u2" ELSE "u1"
ModelOf(b) == CASE b \in {"g1", "g2", "native"} -> "gemini-3-pro"
[] b = "g4" -> "gemini-4-pro"
[] b = "alias" -> "team-model"
[] b = "other" -> "team-claude"
Routed(b) == CASE b = "alias" -> "gemini/gemini-3-pro" \* litellm_params.model
[] b = "other" -> "anthropic/claude-sonnet"
[] OTHER -> ModelOf(b)
LiteLlm(b) == b # "native"
RunsGemini(b) == b \in {"g1", "g2", "g4", "alias", "native"}

\* The names that isLiteLLMThoughtSignatureModel matches.
SignatureModelNames == {"gemini-3-pro", "gemini-4-pro", "gemini/gemini-3-pro"}
NameMatch(name) == name \in SignatureModelNames
\* requiresThoughtSignatures from getLiteLLMModels.
Flagged(b) == NameMatch(Routed(b))
\* The bypass condition in createMessage. listed: the catalog has the model id.
Detected(t, listed) == (listed /\ Flagged(t)) \/ NameMatch(ModelOf(t))
\* The catalog outcomes that NoRejectedCall covers.
Listed == {TRUE}

\* thoughtSignatureOrigin(litellmBaseUrl || default, modelId).
Origin(b) == Url(b) \o "|" \o ModelOf(b)

None == [by |-> "none", step |-> 0]
Bypass == [by |-> "bypass", step |-> 0]
Real(s) == s.by \in Backends
\* getThoughtSignatureOrigin of the handler that streamed the message. Native Gemini stores none.
StoredOrigin(m) == IF LiteLlm(m.by) /\ Real(m.sig) THEN Origin(m.by) ELSE "none"
Sigs == {None, Bypass} \cup [by : Backends, step : Nat \ {0}]
Message == [by : Backends, n : 1..2, marker : BOOLEAN, sig : Sigs]

TypeOK == history \in Seq(Message)

Init == history = <<>>

\* lastThoughtSignature after the stream. createMessage resets it per request.
Captured(t, k, minted) == IF minted THEN [by |-> t, step |-> k] ELSE None

\* A turn on backend t returns n tool calls. A Gemini backend can sign the first call.
\* LiteLLM then also writes the signature into the id of that call, after __thought__.
Turn(t, n, minted) ==
LET k == Len(history) + 1
IN /\ minted => RunsGemini(t)
/\ history' = Append(history, [by |-> t, n |-> n, marker |-> minted /\ LiteLlm(t),
sig |-> Captured(t, k, minted)])

Next == \E t \in Backends, n \in 1..2, minted \in BOOLEAN : Turn(t, n, minted)
Spec == Init /\ [][Next]_history

\* applyThoughtSignatures sends a stored signature only to the backend that minted it.
OriginMatches(m, t) == StoredOrigin(m) = Origin(t)
\* Gemini signs only the first call of a step.
SignedCall(i) == i = 1
\* A sanitized __thought__ id gets the bypass only for a model missing from the catalog.
MarkerFallback(m, listed, i) == m.marker /\ i = 1 /\ ~listed
\* convertAnthropicContentToGemini uses only a signature without an origin.
NativeUses(m) == StoredOrigin(m) = "none"

\* The signature that a request to backend t puts on call i of history message k.
Sent(t, listed, k, i) ==
LET m == history[k]
IN IF LiteLlm(t)
THEN IF Real(m.sig) /\ OriginMatches(m, t) /\ SignedCall(i) THEN m.sig
ELSE IF Detected(t, listed) \/ MarkerFallback(m, listed, i) THEN Bypass
ELSE None
ELSE IF Real(m.sig) /\ NativeUses(m) THEN m.sig ELSE Bypass

\* LiteLLM decodes the sanitized __thought__ id of a call that has no field.
DecodesCorruptId(t, listed, k, i) ==
RunsGemini(t) /\ LiteLlm(t) /\ Sent(t, listed, k, i) = None /\ history[k].marker /\ i = 1

\* The sink oracle. A backend that does not run Gemini rejects every call with the field.
Rejected(t, listed, k, i) ==
LET s == Sent(t, listed, k, i)
IN \/ DecodesCorruptId(t, listed, k, i)
\/ ~RunsGemini(t) /\ s # None
\/ RunsGemini(t) /\ Real(s) /\ (s.by # t \/ s.step # k)
\/ RunsGemini(t) /\ Real(s) /\ LiteLlm(t) /\ i # 1
\/ RunsGemini(t) /\ s = None /\ i = 1
\* Review ratchet (PR 2119):
\* covered: CodeRabbit 4396808577 and edelauna on tool-id.ts. The history sanitizes the id copy (marker rule).
\* added: CodeRabbit 4532185300. Two gateways with one model id share an origin (ModelOnly).
\* gap: 4532185306 (a throw and a reasoning id), 4532185311 (test helper). The spec has no ids or exceptions.
\* gap: edelauna R1 path test, CodeRabbit on sanitizeLiteLlmCallId and its test. The PR removed that code.
\* spec file: CodeRabbit 4634073736. The variants moved to ThoughtSignatureMC.tla. No verdict or state count changed.
\* spec file: CodeRabbit 4650658263. CapturedNative called Captured, its own replacement. The Legacy violation hid it.
\* Rounds 2 and 3 are not review findings. Round 2 fixes the round 1 finding of this spec.
\* Round 3 comes from a web search for best practice (BerriAI/litellm#19739, vercel/ai#15550).
\* Round 4 comes from the simplify pass. A property must constrain the result, not only reject a crash.

\* Safety: no backend rejects a tool call in the history.
NoRejectedCall ==
\A t \in Backends, listed \in Listed, k \in 1..Len(history) :
\A i \in 1..history[k].n : ~Rejected(t, listed, k, i)

\* Safety: for a model in the catalog or not, LiteLLM never decodes a sanitized __thought__ id.
NoCorruptIdDecode ==
\A t \in Backends, listed \in BOOLEAN, k \in 1..Len(history) :
\A i \in 1..history[k].n : ~DecodesCorruptId(t, listed, k, i)

\* Safety: a LiteLLM backend gets back the signature it minted, on the first call of that message.
SignatureDelivered ==
\A t \in Backends, listed \in BOOLEAN, k \in 1..Len(history) :
LiteLlm(t) /\ history[k].by = t /\ Real(history[k].sig) => Sent(t, listed, k, 1) = history[k].sig

====
35 changes: 35 additions & 0 deletions docs/architecture/tla/ThoughtSignatureMC.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---- MODULE ThoughtSignatureMC ----
\* Model-checking settings and variants for ThoughtSignature. Each config replaces operators with these.
EXTENDS ThoughtSignature

CONSTANT MaxTurns
Bounded == Len(history) <= MaxTurns

\* OldRegex and Legacy: the matcher before the PR (Gemini 3 and 2.5 only).
OldNames == {"gemini-3-pro", "gemini/gemini-3-pro"}
\* NameOnly and Legacy: no catalog flag.
NoFlag(b) == FALSE
\* Unlisted: the model can be missing from the catalog.
AnyListed == BOOLEAN
\* ModelOnly: the origin ignores litellmBaseUrl.
ModelOrigin(b) == ModelOf(b)
\* NoOrigin: no origin check.
AnyOrigin(m, t) == TRUE
\* AllCalls: a signature on every parallel call.
EveryCall(i) == TRUE
\* NoMarker and Legacy: no __thought__ fallback.
NoMarkerFallback(m, listed, i) == FALSE
\* MarkerAlways: the round 2 code. The __thought__ fallback also applies to a listed model.
MarkerAlways(m, listed, i) == m.marker /\ i = 1
\* DropStored: applyThoughtSignatures never sends a stored signature.
NeverMatch(m, t) == FALSE
\* NativeLeak: native Gemini uses a LiteLLM signature.
NativeAny(m) == TRUE
\* NoReset: lastThoughtSignature keeps the value from the last request on this handler.
CapturedKept(t, k, minted) ==
IF k > 1 /\ history[k - 1].by = t /\ Real(history[k - 1].sig) THEN history[k - 1].sig
ELSE IF minted THEN [by |-> t, step |-> k] ELSE None
\* Legacy: the old LiteLLM handler did not read the signature.
CapturedNative(t, k, minted) == IF ~LiteLlm(t) /\ minted THEN [by |-> t, step |-> k] ELSE None

====
5 changes: 4 additions & 1 deletion docs/architecture/tla/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ for spec in $specs; do
if [ $all = 1 ] && ! ls "$spec".*.cfg >/dev/null 2>&1; then continue; fi
echo "WRONG $spec.cfg is missing"; bad=1; continue
fi
# The configs check SpecMC.tla when it exists. It holds the model-checking settings.
module=$spec.tla
[ ! -f "${spec}MC.tla" ] || module=${spec}MC.tla
for cfg in "$spec".cfg "$spec".*.cfg; do
[ -f "$cfg" ] || continue
want=pass
[ "$cfg" = "$spec.cfg" ] || want=fail
java -XX:+UseParallelGC -cp "$TLA_JAR" tlc2.TLC -metadir "$(mktemp -d -p "$meta")/s" -config "$cfg" "$spec.tla" >"$meta/out" 2>&1
java -XX:+UseParallelGC -cp "$TLA_JAR" tlc2.TLC -metadir "$(mktemp -d -p "$meta")/s" -config "$cfg" "$module" >"$meta/out" 2>&1
got=unknown
grep -q "No error has been found" "$meta/out" && got=pass
grep -q "violated" "$meta/out" && got=fail
Expand Down
31 changes: 30 additions & 1 deletion packages/types/src/__tests__/lite-llm.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { isLiteLLMPreserveReasoningModel, LITELLM_PRESERVE_REASONING_MODEL_IDS } from "../providers/lite-llm.js"
import {
isLiteLLMPreserveReasoningModel,
isLiteLLMThoughtSignatureModel,
LITELLM_PRESERVE_REASONING_MODEL_IDS,
} from "../providers/lite-llm.js"

describe("LiteLLM preserveReasoning model detection", () => {
it("matches every explicitly listed model id", () => {
Expand Down Expand Up @@ -48,3 +52,28 @@ describe("LiteLLM preserveReasoning model detection", () => {
expect(isLiteLLMPreserveReasoningModel(undefined)).toBe(false)
})
})

describe("LiteLLM thought signature model detection", () => {
it.each([
"gemini-3-pro",
"gemini-3-flash",
"gemini-3.1-pro-preview",
"gemini-2.5-pro",
"gemini-4-pro",
"Gemini 3 Pro",
"gemini 2.5 flash",
"google/gemini-3-pro",
"vertex_ai/gemini-2.5-pro",
"vertex_ai/gemini 2.5 pro",
"gemini/gemini-4-flash",
])("matches %s", (modelName) => {
expect(isLiteLLMThoughtSignatureModel(modelName)).toBe(true)
})

it.each(["gpt-4", "claude-3-opus", "gemini-1.5-pro", "gemini-2.0-flash", "team-model", "", undefined])(
"does not match %s",
(modelName) => {
expect(isLiteLLMThoughtSignatureModel(modelName)).toBe(false)
},
)
})
2 changes: 2 additions & 0 deletions packages/types/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export const modelInfoSchema = z.object({
.optional(),
requiredReasoningEffort: z.boolean().optional(),
preserveReasoning: z.boolean().optional(),
// The model behind a gateway alias validates Gemini thought signatures on function calls.
requiresThoughtSignatures: z.boolean().optional(),
// Some OpenAI-compatible gateways require a Responses-backed route for tool calls.
requiresResponsesApi: z.boolean().optional(),
supportedParameters: z.array(modelParametersSchema).optional(),
Expand Down
9 changes: 9 additions & 0 deletions packages/types/src/providers/lite-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@

return modelId !== undefined && LITELLM_PRESERVE_REASONING_MODEL_ID_SET.has(modelId)
}

/**
* Checks whether `modelName` (a LiteLLM alias or routed `litellm_params.model`
* value) names a Gemini 2.5 or later model. These models validate thought
* signatures on function calls.
*/
export function isLiteLLMThoughtSignatureModel(modelName: string | undefined): boolean {
return /gemini[-\s](?:2\.5|[3-9]|[1-9]\d)/i.test(modelName ?? "")

Check warning on line 107 in packages/types/src/providers/lite-llm.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/lite-llm.ts:107: 2 mutation test gaps; example: Survived Regex mutant (replacement: /gemini[-\s](?:2\.5|[3-9]|[^1-9]\d)/i). See the job summary for the complete list and resolution guidance.
}
Loading
Loading