Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a890511
chore: pin the core dependency to a tag instead of tracking main (#25)
fylorn Sep 23, 2026
a90e9f3
feat!: forward what can be forwarded, convert only what must be (#26)
fylorn Sep 23, 2026
ca7647c
refactor: take the circuit-breaker registry and metric labels back fr…
fylorn Sep 23, 2026
a6678cf
refactor: redact PII with core's guard engine, and restore tool argum…
fylorn Sep 23, 2026
437a671
feat: inspect the tool calls an upstream returns (#29)
fylorn Sep 23, 2026
038796b
build: keep only line tables in dev and test builds (#30)
fylorn Sep 24, 2026
05f52e8
feat: one circuit-breaker state machine, and hidden characters in req…
fylorn Sep 24, 2026
8a76395
fix: make the integration suite pass again (#32)
fylorn Sep 24, 2026
6482690
test: fix the two flaky integration tests (#33)
fylorn Sep 24, 2026
9f46116
fix: bill a Chat stream whose caller did not ask for usage (#34)
fylorn Sep 24, 2026
3c35ab8
fix: a request the upstream refuses no longer fails over or trips bre…
fylorn Sep 24, 2026
234fcce
Merge main (v1.1.0) into dev
fylorn Sep 24, 2026
82f8061
docs: cut releases from a release branch, and keep the tag's headings…
fylorn Sep 24, 2026
bd57b5d
ci: run checks on pull requests into dev, including the integration s…
fylorn Sep 24, 2026
c1b2085
fix: bill cached input at cache prices, estimate missing usage, strip…
fylorn Sep 24, 2026
ad5b75b
refactor: take back what only this side used from core (#41)
fylorn Sep 24, 2026
3a617f3
feat(gateway): take official hosts, output fallback and error shapes …
fylorn Sep 24, 2026
ed1c8b5
feat(gateway): accept Gemini clients, and the Responses API over a We…
fylorn Sep 24, 2026
28d4387
test: count the probes that miss before the streaming cache hit (#44)
fylorn Sep 24, 2026
d3f36fc
refactor(server): move the catalog's SQL into repositories (#45)
fylorn Sep 24, 2026
83e9bcc
refactor(server): move the dashboard, limits and log-forwarding handl…
fylorn Sep 24, 2026
9b5b326
refactor(server): move the MCP handlers' SQL into repositories (#50)
fylorn Sep 24, 2026
86beb82
refactor(gateway): run the request guards on core's tw-guard engines …
fylorn Sep 24, 2026
1c80b83
refactor(server): move the identity handlers' SQL into repositories (…
fylorn Sep 24, 2026
c25b44f
fix(mcp): revoking a default connection no longer fails with a 500 (#51)
fylorn Sep 24, 2026
dbce845
test: leave the cancelled stream after it has started, not on a timer…
fylorn Sep 24, 2026
c3d2d57
refactor(server): move the access handlers' SQL into repositories (#48)
fylorn Sep 24, 2026
d92c2d1
fix(settings): read security.totp_required as a boolean, and seed aut…
fylorn Sep 24, 2026
7e95183
feat(gateway): record a client that leaves before its response exists…
fylorn Sep 24, 2026
367df3c
feat(auth): enforce the TOTP requirement (#55)
fylorn Sep 24, 2026
443de8d
feat(gateway): keep the last response on a Responses WebSocket (#56)
fylorn Sep 24, 2026
6890c72
Merge main (v2.0.0) into dev
fylorn Sep 24, 2026
d4f6d5a
docs(release): CI runs the integration suite on the release PR (#58)
fylorn Sep 24, 2026
ef3de87
docs(contributing): point vulnerability reports at the organization's…
fylorn Sep 25, 2026
c4f8b1c
docs(readme): current description of ThinkWatch Lite and ThinkWatch C…
fylorn Sep 25, 2026
f259962
feat(providers): authenticate Bedrock with an API key (#61)
fylorn Sep 28, 2026
78f9ab5
test: hold the early-cancel client once its key is known, not on a ti…
fylorn Sep 28, 2026
1b752f2
feat(providers): list Bedrock's models, and let the route editor take…
fylorn Sep 28, 2026
1f08421
fix(bedrock): refuse keys that will not decrypt, and keep instance-ro…
fylorn Sep 28, 2026
e480bfd
refactor(bedrock): use core's shared tw-bedrock, and core v0.55.0 (#65)
fylorn Sep 29, 2026
e1e7999
docs(readme): rewrite both READMEs to be short and accurate (#66)
fylorn Sep 30, 2026
af9eb81
Merge main (v2.1.0) into dev
fylorn Sep 30, 2026
ed6dd39
docs(readme): 37 MCP templates, what the setup wizard does, body reda…
fylorn Sep 30, 2026
9afcc08
fix(rbac): make the seeded team_manager work at team scope (#69)
fylorn Sep 30, 2026
fa3a5b9
fix(rbac): require gateway use, and count only grants that give it (#70)
fylorn Sep 30, 2026
a1eed6f
Merge main (v2.2.0) into dev
fylorn Sep 30, 2026
da88b09
Merge main (sponsor line) into dev
fylorn Oct 2, 2026
1a399e7
Allow clippy::double_must_use on the async_trait BlobStore (#73)
fylorn Oct 2, 2026
8d8d96f
Unify the request guards with thinkwatch-core's rule model (#72)
fylorn Oct 3, 2026
2baa123
Fix what the pre-release review of the guard unification found (#75)
fylorn Oct 3, 2026
33c22dc
Merge main (v3.0.0) into dev
fylorn Oct 3, 2026
dcc8616
Merge main (README: ThinkWatch Lite for individual developers) into dev
fylorn Oct 4, 2026
6b73344
Merge main (v3.1.0) into dev
fylorn Oct 5, 2026
03c393c
Usage limits: token limits refuse, key limits count on the key, Retry…
fylorn Oct 5, 2026
4075855
fix(redis): connect over TLS for rediss:// URLs (#82)
fylorn Oct 5, 2026
33234ee
Concurrent startup, body retention on restart, and Helm network polic…
fylorn Oct 5, 2026
b7a34e1
Merge main (v3.2.0) into dev
fylorn Oct 5, 2026
2ce6471
chore(deps): update rust crate rand to v0.10.1 [security] (#77)
renovate[bot] Oct 6, 2026
0682864
chore(deps): update rust crate xxhash-rust to v0.8.16 [security] (#78)
renovate[bot] Oct 6, 2026
1fbe7bd
chore(deps): take the Renovate dashboard upgrades (#85)
fylorn Oct 6, 2026
2e23fd9
chore(deps): pnpm 12, and ClickHouse row validation on (#86)
fylorn Oct 6, 2026
977cab0
ci: save Rust caches only on pushes, and let releases read CI's image…
fylorn Oct 8, 2026
a19ed65
Merge main (v3.2.1) into dev
fylorn Oct 8, 2026
ea2a81f
Merge main (v3.3.0) into dev
fylorn Oct 9, 2026
e8ae1f1
Stream endings and in-stream errors logged like answers; core v0.68.0…
fylorn Oct 10, 2026
0e070a9
Merge main (v3.3.1) into dev
fylorn Oct 10, 2026
8376c6d
fix(gateway): assemble a forwarded Chat answer as the caller received it
fylorn Oct 10, 2026
61466c0
chore(release): tag 3.4.0
fylorn Oct 10, 2026
c8e0bec
chore(release): pin thinkwatch-core v0.69.0 and use Session::keep_tex…
fylorn Oct 10, 2026
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
75 changes: 74 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,78 @@ target.

## [Unreleased]

## [3.4.0] — 2026-10-11

Conversations with reasoning models behind Chat-format upstreams keep their
reasoning from turn to turn, Gemini's tool loops keep their thought
signatures through a conversion, and a tool call that a Chat-format model
writes into its answer text reaches the caller as a tool call. The
thinkwatch-core crates move from v0.68.0 to v0.69.0.

### Read before upgrading

- **Converted answers from Chat-format upstreams can carry tool calls that
arrived as text before.** Self-hosted and relayed Chat-format models
(DeepSeek, GLM, Qwen, Llama and others) sometimes write a tool call into
`content` in the template they were trained on instead of answering with
`tool_calls`. On a route that converts the request to the Chat format,
such a call to a tool the request defined now reaches the caller as a
structured tool call, which the caller executes, where it used to be a
tagged piece of prose the caller showed and did nothing with. Tool-call
inspection sees these calls like any other and refuses or cuts them under
the same rules; the request log's response body records them as tool
calls, and a recovered call ends the answer with the tool-use stop reason
instead of `stop`. A request that defined no tools, a name the request
did not define, and a bare JSON object in prose stay text. A Chat caller
on a Chat-format route is forwarded as sent and unchanged. No setting,
schema, API route, Helm value or Redis key changes.

### Fixed

- **Gemini thought signatures are not counted as answer text.** When a
request's usage has to be estimated (`usage_estimated`), the
`thoughtSignature` on a Gemini thought or function call — an opaque blob
of up to several kilobytes — was counted as output text; it is left out
now, as the other formats' reasoning signatures were.

### Changed

- thinkwatch-core crates (tw-bedrock, tw-breaker, tw-dialect, tw-guard)
v0.68.0 → v0.69.0. Only tw-dialect changes:
- **Reasoning from a Chat-format upstream round-trips** (tw-dialect).
Reasoning a Chat-format upstream returned (`reasoning_content`, or
`reasoning` as OpenRouter and vLLM call it) was dropped from the next
turn's request on every route, so a Claude Code or Codex conversation
with tools against DeepSeek, which requires the reasoning of a
tool-calling turn on the following requests of that turn, lost it every
turn. Such reasoning is now carried in the caller's own format with a
`tw1.ch.` signature, read back on the next turn, and written as
`reasoning_content` only to a Chat-format upstream; to an upstream of
another format it is left out as before, and reasoning another vendor
signed is still not sent to a Chat-format upstream. Consecutive
assistant messages are merged before a request is written in the Chat
format, so a Responses caller's reasoning, text and tool call of one
turn arrive as one message. The reasoning history a request carries
back counts as its input, so the input tokens of those turns grow by
it, as the upstream charges them.
- **Gemini thought signatures on function calls are kept** (tw-dialect).
Gemini with thinking puts a turn's thought signature on the first
`functionCall` part, and the conversion only read signatures from
thought parts, so a converted Gemini tool loop lost the signature and
with it the model's reasoning continuity. The signature on a function
call is now carried through a conversion and written back on the
`functionCall` part; a call with no real signature gets the
`skip_thought_signature_validator` placeholder as before. A Gemini
request forwarded as sent that carries a signature from another route
on a `functionCall` part keeps the part with the placeholder, where the
part was removed and the tool loop broke.
- **Tool calls written into a Chat-format upstream's answer text are
recognised** (tw-dialect): see Read before upgrading. In this edition
the answer assembled for the request log and the cache of a Chat
caller's stream forwarded as sent to a Chat-format upstream keeps such
a call as the text the caller received, rather than the structured call
the conversion would have made of it.

## [3.3.1] — 2026-10-10

Streams are logged as they ended. A caller that hangs up once it has read
Expand Down Expand Up @@ -1696,7 +1768,8 @@ unreleased builds should: stop the gateway, run `db/schema.sql`
against PostgreSQL, restart against this tag. The schema is
idempotent end-to-end, so the apply is safe to repeat.

[Unreleased]: https://github.com/ThinkWatchProject/ThinkWatch/compare/v3.3.1...HEAD
[Unreleased]: https://github.com/ThinkWatchProject/ThinkWatch/compare/v3.4.0...HEAD
[3.4.0]: https://github.com/ThinkWatchProject/ThinkWatch/releases/tag/v3.4.0
[3.3.1]: https://github.com/ThinkWatchProject/ThinkWatch/releases/tag/v3.3.1
[3.3.0]: https://github.com/ThinkWatchProject/ThinkWatch/releases/tag/v3.3.0
[3.2.1]: https://github.com/ThinkWatchProject/ThinkWatch/releases/tag/v3.2.1
Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = [
]

[workspace.package]
version = "3.3.1"
version = "3.4.0"
edition = "2024"
# The MSRV: the newest `rust-version` among the locked dependencies
# (sqlx 0.9 and the aws-smithy crates under aws-sigv4). Without it,
Expand Down Expand Up @@ -70,10 +70,10 @@ opt-level = 3
# never re-exported through a local shim. And the reverse: something only
# this side uses (the at-rest crypto, IMDSv2 credentials, the gateway error)
# lives here, not in core.
tw-bedrock = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.68.0" }
tw-breaker = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.68.0" }
tw-dialect = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.68.0" }
tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.68.0" }
tw-bedrock = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.69.0" }
tw-breaker = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.69.0" }
tw-dialect = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.69.0" }
tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.69.0" }

# Web framework
axum = { version = "0.8", features = ["macros", "ws"] }
Expand Down
68 changes: 67 additions & 1 deletion crates/gateway/src/proxy/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ impl Outbound {
/// compaction would be recorded as a failed one. A request the
/// conversion layer cannot read at all can still be forwarded, and its
/// answer is assembled knowing only the model and whether it streams.
///
/// A Chat upstream can write a tool call into its answer text instead
/// of `tool_calls`. A converted answer turns such a call, when the
/// request defined the tool, into a structured one (see
/// `tw_dialect::chat::text_calls`); a forwarded answer reaches the
/// caller as the upstream wrote it, text included, and is assembled as
/// that (`Session::keep_text_calls`).
fn forwarded_session(&self, body: &Value, model: &str, target: &Target) -> Session {
let client = self.surface.dialect;
let request =
Expand All @@ -368,7 +375,9 @@ impl Outbound {
..Default::default()
},
};
tw_dialect::convert::encode(&request, target).session
tw_dialect::convert::encode(&request, target)
.session
.keep_text_calls()
}

/// Address the request to `protocol`, naming `model` upstream.
Expand Down Expand Up @@ -1273,6 +1282,63 @@ mod tests {
assert!(converted.convert.as_ref().unwrap().is_compaction());
}

/// A Chat upstream that writes a tool call into its text: a converted
/// answer carries it as a structured call, a forwarded one is assembled
/// as the caller received it — text.
#[test]
fn a_tool_call_written_into_text_is_assembled_as_the_caller_received_it() {
const STREAM: &str = concat!(
"data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,",
"\"delta\":{\"role\":\"assistant\",\"content\":\"<tool_call>{\\\"name\\\": \\\"ls\\\", ",
"\\\"arguments\\\": {\\\"path\\\": \\\"/\\\"}}</tool_call>\"}}]}\n\n",
"data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,",
"\"delta\":{},\"finish_reason\":\"stop\"}]}\n\n",
"data: [DONE]\n\n"
);
let tools = serde_json::json!([{
"type": "function",
"function": {"name": "ls", "parameters": {"type": "object"}}
}]);
let assemble = |session: &Session| -> Value {
let mut c = session.collector();
c.process(STREAM.as_bytes());
serde_json::from_slice(&c.finish().unwrap()).unwrap()
};

let ask = serde_json::json!({
"model": "m", "stream": true, "tools": tools,
"messages": [{"role": "user", "content": "list /"}]
});
let forwarded = outbound(CHAT, "/v1/chat/completions", ask, None)
.address(UpstreamProtocol::OpenAiChat, "m", false)
.unwrap_or_else(|e| panic!("{e:?}"));
assert!(forwarded.convert.is_none());
let message = &assemble(&forwarded.collect)["choices"][0]["message"];
assert!(
message["content"].as_str().unwrap().contains("<tool_call>"),
"{message}"
);
assert!(message.get("tool_calls").is_none(), "{message}");

let ask = serde_json::json!({
"model": "m", "stream": true, "max_tokens": 100,
"tools": [{"name": "ls", "input_schema": {"type": "object"}}],
"messages": [{"role": "user", "content": "list /"}]
});
let converted = outbound(MESSAGES, "/v1/messages", ask, None)
.address(UpstreamProtocol::OpenAiChat, "m", false)
.unwrap_or_else(|e| panic!("{e:?}"));
let content = &assemble(converted.convert.as_ref().unwrap())["content"];
assert!(
content
.as_array()
.unwrap()
.iter()
.any(|b| b["type"] == "tool_use" && b["name"] == "ls"),
"{content}"
);
}

/// Only breakpoints the conversion added may be taken out when an
/// upstream refuses them; the caller's own are its decision.
#[test]
Expand Down
11 changes: 11 additions & 0 deletions crates/gateway/src/usage_estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ fn text_len(v: &Value, skip: &[&str]) -> usize {
"call_id",
"tool_call_id",
"signature",
"thoughtSignature",
"thought_signature",
"encrypted_content",
];
match v {
Expand Down Expand Up @@ -175,6 +177,15 @@ mod tests {
],
});
assert_eq!(answer_tokens(body.to_string().as_bytes()), 2);
// Gemini's, on a thought and on the function call it led to.
let body = json!({
"candidates": [{"content": {"parts": [
{"text": "abcd", "thought": true, "thoughtSignature": "x".repeat(4000)},
{"functionCall": {"name": "ls", "args": {}}, "thoughtSignature": "x".repeat(4000)},
{"functionCall": {"name": "ls", "args": {}}, "thought_signature": "x".repeat(4000)}
]}}],
});
assert_eq!(answer_tokens(body.to_string().as_bytes()), 2);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/think-watch/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: think-watch
description: Enterprise AI API Gateway & MCP Management Platform
type: application
version: 3.3.1
appVersion: "3.3.1"
version: 3.4.0
appVersion: "3.4.0"
keywords:
- ai
- gateway
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "web",
"private": true,
"version": "3.3.1",
"version": "3.4.0",
"type": "module",
"packageManager": "pnpm@12.9.1",
"scripts": {
Expand Down
Loading