Compare commits

..

9 Commits

Author SHA1 Message Date
Patrick Buckley 83cfea36b0 chore: bump version to 1.3.0a2 2026-04-08 18:07:12 -07:00
Patrick Buckley 12516ffa04 fix(ui): remove broken hint animation and restore card toggle
The ws-check-hint animation clobbered the fadein's forwards fill,
making the checkbox invisible for 0.6s on card-body click — appearing
as a deselect-then-reselect. Remove the hint, the unused role=checkbox
on the card, and restore the original symmetric toggle behavior.
2026-04-08 18:06:54 -07:00
Patrick Buckley c33ad168c7 fix(ui): improve delete workstream UX and accessibility (#339)
* fix(ui): improve delete workstream UX and accessibility

Card body click no longer deselects (prevents confusing red border loss);
checkbox pulse hint guides users to deselect affordance. Adds keyboard
navigation, aria-labels, hover feedback, animations, and neutral Close
button styling after deletion.

* fix(ui): remove duplicate a11y checkbox from delete-mode cards

Hide the visual checkbox from the a11y tree and tab order so the card
(role=checkbox) is the sole keyboard/screen-reader target. Addresses
Copilot review feedback about nested interactive elements.
2026-04-08 17:18:59 -07:00
Patrick Buckley fd1fb7d849 chore(deps): bump lacme to >=1.0.5 (cryptography security update) 2026-04-08 16:48:06 -07:00
renovate[bot] 58b2d01b1c chore(deps): lock file maintenance (#338)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-08 16:10:27 -07:00
renovate[bot] b8440d70ac chore(deps): update ghcr.io/astral-sh/uv docker tag to v0.11.5 (#337)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-08 16:08:22 -07:00
renovate[bot] b2206337fe chore(deps): update dependency vitest to v4.1.3 (#336)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-08 16:08:09 -07:00
renovate[bot] fadb198898 chore(deps): update pypa/gh-action-pypi-publish digest to cef2210 (#335)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-08 16:07:50 -07:00
Patrick Buckley b1e78b79fb chore: bump version to 1.3.0a1 2026-04-07 00:38:16 -07:00
12 changed files with 228 additions and 636 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ jobs:
if: steps.tag.outputs.skip == 'false'
- run: python -m build
if: steps.tag.outputs.skip == 'false'
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
if: steps.tag.outputs.skip == 'false'
- name: Create GitHub Release
+1 -1
View File
@@ -8,7 +8,7 @@ FROM python:3.14-slim
LABEL org.opencontainers.image.title="turnstone" \
org.opencontainers.image.description="Multi-node AI orchestration platform"
COPY --from=ghcr.io/astral-sh/uv:0.11.3 /uv /usr/local/bin/uv
COPY --from=ghcr.io/astral-sh/uv:0.11.5 /uv /usr/local/bin/uv
# Remove the slim image's man page exclusion so man-db has actual content
RUN rm -f /etc/dpkg/dpkg.cfg.d/docker
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "turnstone"
version = "1.2.2"
version = "1.3.0a2"
description = "Multi-node AI orchestration platform with tool use, agent routing, and cluster simulation."
readme = "README.md"
license = "BUSL-1.1"
+181 -144
View File
@@ -14,38 +14,35 @@
}
},
"node_modules/@emnapi/core": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.2.tgz",
"integrity": "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==",
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.1.tgz",
"integrity": "sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"@emnapi/wasi-threads": "1.2.1",
"@emnapi/wasi-threads": "1.2.0",
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.2.tgz",
"integrity": "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==",
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.1.tgz",
"integrity": "sha512-VYi5+ZVLhpgK4hQ0TAjiQiZ6ol0oe4mBx7mVv7IflsiEp0OWoVsp/+f9Vc1hOhE0TtkORVrI1GvzyreqpgWtkA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/wasi-threads": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
"integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.0.tgz",
"integrity": "sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
@@ -58,9 +55,9 @@
"license": "MIT"
},
"node_modules/@napi-rs/wasm-runtime": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.2.tgz",
"integrity": "sha512-sNXv5oLJ7ob93xkZ1XnxisYhGYXfaG9f65/ZgYuAu3qt7b3NadcOEhLvx28hv31PgX8SZJRYrAIPQilQmFpLVw==",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.3.tgz",
"integrity": "sha512-xK9sGVbJWYb08+mTJt3/YV24WxvxpXcXtP6B172paPZ+Ts69Re9dAr7lKwJoeIx8OoeuimEiRZ7umkiUVClmmQ==",
"dev": true,
"license": "MIT",
"optional": true,
@@ -77,9 +74,9 @@
}
},
"node_modules/@oxc-project/types": {
"version": "0.122.0",
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.122.0.tgz",
"integrity": "sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==",
"version": "0.123.0",
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.123.0.tgz",
"integrity": "sha512-YtECP/y8Mj1lSHiUWGSRzy/C6teUKlS87dEfuVKT09LgQbUsBW1rNg+MiJ4buGu3yuADV60gbIvo9/HplA56Ew==",
"dev": true,
"license": "MIT",
"funding": {
@@ -87,9 +84,9 @@
}
},
"node_modules/@rolldown/binding-android-arm64": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.12.tgz",
"integrity": "sha512-pv1y2Fv0JybcykuiiD3qBOBdz6RteYojRFY1d+b95WVuzx211CRh+ytI/+9iVyWQ6koTh5dawe4S/yRfOFjgaA==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.13.tgz",
"integrity": "sha512-5ZiiecKH2DXAVJTNN13gNMUcCDg4Jy8ZjbXEsPnqa248wgOVeYRX0iqXXD5Jz4bI9BFHgKsI2qmyJynstbmr+g==",
"cpu": [
"arm64"
],
@@ -104,9 +101,9 @@
}
},
"node_modules/@rolldown/binding-darwin-arm64": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.12.tgz",
"integrity": "sha512-cFYr6zTG/3PXXF3pUO+umXxt1wkRK/0AYT8lDwuqvRC+LuKYWSAQAQZjCWDQpAH172ZV6ieYrNnFzVVcnSflAg==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.13.tgz",
"integrity": "sha512-tz/v/8G77seu8zAB3A5sK3UFoOl06zcshEzhUO62sAEtrEuW/H1CcyoupOrD+NbQJytYgA4CppXPzlrmp4JZKA==",
"cpu": [
"arm64"
],
@@ -121,9 +118,9 @@
}
},
"node_modules/@rolldown/binding-darwin-x64": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.12.tgz",
"integrity": "sha512-ZCsYknnHzeXYps0lGBz8JrF37GpE9bFVefrlmDrAQhOEi4IOIlcoU1+FwHEtyXGx2VkYAvhu7dyBf75EJQffBw==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.13.tgz",
"integrity": "sha512-8DakphqOz8JrMYWTJmWA+vDJxut6LijZ8Xcdc4flOlAhU7PNVwo2MaWBF9iXjJAPo5rC/IxEFZDhJ3GC7NHvug==",
"cpu": [
"x64"
],
@@ -138,9 +135,9 @@
}
},
"node_modules/@rolldown/binding-freebsd-x64": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.12.tgz",
"integrity": "sha512-dMLeprcVsyJsKolRXyoTH3NL6qtsT0Y2xeuEA8WQJquWFXkEC4bcu1rLZZSnZRMtAqwtrF/Ib9Ddtpa/Gkge9Q==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.13.tgz",
"integrity": "sha512-4wBQFfjDuXYN/SVI8inBF3Aa+isq40rc6VMFbk5jcpolUBTe5cYnMsHZ51nFWsx3PVyyNN3vgoESki0Hmr/4BA==",
"cpu": [
"x64"
],
@@ -155,9 +152,9 @@
}
},
"node_modules/@rolldown/binding-linux-arm-gnueabihf": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.12.tgz",
"integrity": "sha512-YqWjAgGC/9M1lz3GR1r1rP79nMgo3mQiiA+Hfo+pvKFK1fAJ1bCi0ZQVh8noOqNacuY1qIcfyVfP6HoyBRZ85Q==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.13.tgz",
"integrity": "sha512-JW/e4yPIXLms+jmnbwwy5LA/LxVwZUWLN8xug+V200wzaVi5TEGIWQlh8o91gWYFxW609euI98OCCemmWGuPrw==",
"cpu": [
"arm"
],
@@ -172,13 +169,16 @@
}
},
"node_modules/@rolldown/binding-linux-arm64-gnu": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.12.tgz",
"integrity": "sha512-/I5AS4cIroLpslsmzXfwbe5OmWvSsrFuEw3mwvbQ1kDxJ822hFHIx+vsN/TAzNVyepI/j/GSzrtCIwQPeKCLIg==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.13.tgz",
"integrity": "sha512-ZfKWpXiUymDnavepCaM6KG/uGydJ4l2nBmMxg60Ci4CbeefpqjPWpfaZM7PThOhk2dssqBAcwLc6rAyr0uTdXg==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -189,13 +189,16 @@
}
},
"node_modules/@rolldown/binding-linux-arm64-musl": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.12.tgz",
"integrity": "sha512-V6/wZztnBqlx5hJQqNWwFdxIKN0m38p8Jas+VoSfgH54HSj9tKTt1dZvG6JRHcjh6D7TvrJPWFGaY9UBVOaWPw==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.13.tgz",
"integrity": "sha512-bmRg3O6Z0gq9yodKKWCIpnlH051sEfdVwt+6m5UDffAQMUUqU0xjnQqqAUm+Gu7ofAAly9DqiQDtKu2nPDEABA==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -206,13 +209,16 @@
}
},
"node_modules/@rolldown/binding-linux-ppc64-gnu": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.12.tgz",
"integrity": "sha512-AP3E9BpcUYliZCxa3w5Kwj9OtEVDYK6sVoUzy4vTOJsjPOgdaJZKFmN4oOlX0Wp0RPV2ETfmIra9x1xuayFB7g==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.13.tgz",
"integrity": "sha512-8Wtnbw4k7pMYN9B/mOEAsQ8HOiq7AZ31Ig4M9BKn2So4xRaFEhtCSa4ZJaOutOWq50zpgR4N5+L/opnlaCx8wQ==",
"cpu": [
"ppc64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -223,13 +229,16 @@
}
},
"node_modules/@rolldown/binding-linux-s390x-gnu": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.12.tgz",
"integrity": "sha512-nWwpvUSPkoFmZo0kQazZYOrT7J5DGOJ/+QHHzjvNlooDZED8oH82Yg67HvehPPLAg5fUff7TfWFHQS8IV1n3og==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.13.tgz",
"integrity": "sha512-D/0Nlo8mQuxSMohNJUF2lDXWRsFDsHldfRRgD9bRgktj+EndGPj4DOV37LqDKPYS+osdyhZEH7fTakTAEcW7qg==",
"cpu": [
"s390x"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -240,13 +249,16 @@
}
},
"node_modules/@rolldown/binding-linux-x64-gnu": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.12.tgz",
"integrity": "sha512-RNrafz5bcwRy+O9e6P8Z/OCAJW/A+qtBczIqVYwTs14pf4iV1/+eKEjdOUta93q2TsT/FI0XYDP3TCky38LMAg==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.13.tgz",
"integrity": "sha512-eRrPvat2YaVQcwwKi/JzOP6MKf1WRnOCr+VaI3cTWz3ZoLcP/654z90lVCJ4dAuMEpPdke0n+qyAqXDZdIC4rA==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -257,13 +269,16 @@
}
},
"node_modules/@rolldown/binding-linux-x64-musl": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.12.tgz",
"integrity": "sha512-Jpw/0iwoKWx3LJ2rc1yjFrj+T7iHZn2JDg1Yny1ma0luviFS4mhAIcd1LFNxK3EYu3DHWCps0ydXQ5i/rrJ2ig==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.13.tgz",
"integrity": "sha512-PsdONiFRp8hR8KgVjTWjZ9s7uA3uueWL0t74/cKHfM4dR5zXYv4AjB8BvA+QDToqxAFg4ZkcVEqeu5F7inoz5w==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -274,9 +289,9 @@
}
},
"node_modules/@rolldown/binding-openharmony-arm64": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.12.tgz",
"integrity": "sha512-vRugONE4yMfVn0+7lUKdKvN4D5YusEiPilaoO2sgUWpCvrncvWgPMzK00ZFFJuiPgLwgFNP5eSiUlv2tfc+lpA==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.13.tgz",
"integrity": "sha512-hCNXgC5dI3TVOLrPT++PKFNZ+1EtS0mLQwfXXXSUD/+rGlB65gZDwN/IDuxLpQP4x8RYYHqGomlUXzpO8aVI2w==",
"cpu": [
"arm64"
],
@@ -291,9 +306,9 @@
}
},
"node_modules/@rolldown/binding-wasm32-wasi": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.12.tgz",
"integrity": "sha512-ykGiLr/6kkiHc0XnBfmFJuCjr5ZYKKofkx+chJWDjitX+KsJuAmrzWhwyOMSHzPhzOHOy7u9HlFoa5MoAOJ/Zg==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.13.tgz",
"integrity": "sha512-viLS5C5et8NFtLWw9Sw3M/w4vvnVkbWkO7wSNh3C+7G1+uCkGpr6PcjNDSFcNtmXY/4trjPBqUfcOL+P3sWy/g==",
"cpu": [
"wasm32"
],
@@ -301,16 +316,18 @@
"license": "MIT",
"optional": true,
"dependencies": {
"@napi-rs/wasm-runtime": "^1.1.1"
"@emnapi/core": "1.9.1",
"@emnapi/runtime": "1.9.1",
"@napi-rs/wasm-runtime": "^1.1.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@rolldown/binding-win32-arm64-msvc": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.12.tgz",
"integrity": "sha512-5eOND4duWkwx1AzCxadcOrNeighiLwMInEADT0YM7xeEOOFcovWZCq8dadXgcRHSf3Ulh1kFo/qvzoFiCLOL1Q==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.13.tgz",
"integrity": "sha512-Fqa3Tlt1xL4wzmAYxGNFV36Hb+VfPc9PYU+E25DAnswXv3ODDu/yyWjQDbXMo5AGWkQVjLgQExuVu8I/UaZhPQ==",
"cpu": [
"arm64"
],
@@ -325,9 +342,9 @@
}
},
"node_modules/@rolldown/binding-win32-x64-msvc": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.12.tgz",
"integrity": "sha512-PyqoipaswDLAZtot351MLhrlrh6lcZPo2LSYE+VDxbVk24LVKAGOuE4hb8xZQmrPAuEtTZW8E6D2zc5EUZX4Lw==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.13.tgz",
"integrity": "sha512-/pLI5kPkGEi44TDlnbio3St/5gUFeN51YWNAk/Gnv6mEQBOahRBh52qVFVBpmrnU01n2yysvBML9Ynu7K4kGAQ==",
"cpu": [
"x64"
],
@@ -342,9 +359,9 @@
}
},
"node_modules/@rolldown/pluginutils": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.12.tgz",
"integrity": "sha512-HHMwmarRKvoFsJorqYlFeFRzXZqCt2ETQlEDOb9aqssrnVBB1/+xgTGtuTrIk5vzLNX1MjMtTf7W9z3tsSbrxw==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.13.tgz",
"integrity": "sha512-3ngTAv6F/Py35BsYbeeLeecvhMKdsKm4AoOETVhAA+Qc8nrA2I0kF7oa93mE9qnIurngOSpMnQ0x2nQY2FPviA==",
"dev": true,
"license": "MIT"
},
@@ -392,16 +409,16 @@
"license": "MIT"
},
"node_modules/@vitest/expect": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.2.tgz",
"integrity": "sha512-gbu+7B0YgUJ2nkdsRJrFFW6X7NTP44WlhiclHniUhxADQJH5Szt9mZ9hWnJPJ8YwOK5zUOSSlSvyzRf0u1DSBQ==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.3.tgz",
"integrity": "sha512-CW8Q9KMtXDGHj0vCsqui0M5KqRsu0zm0GNDW7Gd3U7nZ2RFpPKSCpeCXoT+/+5zr1TNlsoQRDEz+LzZUyq6gnQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@standard-schema/spec": "^1.1.0",
"@types/chai": "^5.2.2",
"@vitest/spy": "4.1.2",
"@vitest/utils": "4.1.2",
"@vitest/spy": "4.1.3",
"@vitest/utils": "4.1.3",
"chai": "^6.2.2",
"tinyrainbow": "^3.1.0"
},
@@ -410,13 +427,13 @@
}
},
"node_modules/@vitest/mocker": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.2.tgz",
"integrity": "sha512-Ize4iQtEALHDttPRCmN+FKqOl2vxTiNUhzobQFFt/BM1lRUTG7zRCLOykG/6Vo4E4hnUdfVLo5/eqKPukcWW7Q==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.3.tgz",
"integrity": "sha512-XN3TrycitDQSzGRnec/YWgoofkYRhouyVQj4YNsJ5r/STCUFqMrP4+oxEv3e7ZbLi4og5kIHrZwekDJgw6hcjw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/spy": "4.1.2",
"@vitest/spy": "4.1.3",
"estree-walker": "^3.0.3",
"magic-string": "^0.30.21"
},
@@ -437,9 +454,9 @@
}
},
"node_modules/@vitest/pretty-format": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.2.tgz",
"integrity": "sha512-dwQga8aejqeuB+TvXCMzSQemvV9hNEtDDpgUKDzOmNQayl2OG241PSWeJwKRH3CiC+sESrmoFd49rfnq7T4RnA==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.3.tgz",
"integrity": "sha512-hYqqwuMbpkkBodpRh4k4cQSOELxXky1NfMmQvOfKvV8zQHz8x8Dla+2wzElkMkBvSAJX5TRGHJAQvK0TcOafwg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -450,13 +467,13 @@
}
},
"node_modules/@vitest/runner": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.2.tgz",
"integrity": "sha512-Gr+FQan34CdiYAwpGJmQG8PgkyFVmARK8/xSijia3eTFgVfpcpztWLuP6FttGNfPLJhaZVP/euvujeNYar36OQ==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.3.tgz",
"integrity": "sha512-VwgOz5MmT0KhlUj40h02LWDpUBVpflZ/b7xZFA25F29AJzIrE+SMuwzFf0b7t4EXdwRNX61C3B6auIXQTR3ttA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/utils": "4.1.2",
"@vitest/utils": "4.1.3",
"pathe": "^2.0.3"
},
"funding": {
@@ -464,14 +481,14 @@
}
},
"node_modules/@vitest/snapshot": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.2.tgz",
"integrity": "sha512-g7yfUmxYS4mNxk31qbOYsSt2F4m1E02LFqO53Xpzg3zKMhLAPZAjjfyl9e6z7HrW6LvUdTwAQR3HHfLjpko16A==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.3.tgz",
"integrity": "sha512-9l+k/J9KG5wPJDX9BcFFzhhwNjwkRb8RsnYhaT1vPY7OufxmQFc9sZzScRCPTiETzl37mrIWVY9zxzmdVeJwDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/pretty-format": "4.1.2",
"@vitest/utils": "4.1.2",
"@vitest/pretty-format": "4.1.3",
"@vitest/utils": "4.1.3",
"magic-string": "^0.30.21",
"pathe": "^2.0.3"
},
@@ -480,9 +497,9 @@
}
},
"node_modules/@vitest/spy": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.2.tgz",
"integrity": "sha512-DU4fBnbVCJGNBwVA6xSToNXrkZNSiw59H8tcuUspVMsBDBST4nfvsPsEHDHGtWRRnqBERBQu7TrTKskmjqTXKA==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.3.tgz",
"integrity": "sha512-ujj5Uwxagg4XUIfAUyRQxAg631BP6e9joRiN99mr48Bg9fRs+5mdUElhOoZ6rP5mBr8Bs3lmrREnkrQWkrsTCw==",
"dev": true,
"license": "MIT",
"funding": {
@@ -490,13 +507,13 @@
}
},
"node_modules/@vitest/utils": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.2.tgz",
"integrity": "sha512-xw2/TiX82lQHA06cgbqRKFb5lCAy3axQ4H4SoUFhUsg+wztiet+co86IAMDtF6Vm1hc7J6j09oh/rgDn+JdKIQ==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.3.tgz",
"integrity": "sha512-Pc/Oexse/khOWsGB+w3q4yzA4te7W4gpZZAvk+fr8qXfTURZUMj5i7kuxsNK5mP/dEB6ao3jfr0rs17fHhbHdw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/pretty-format": "4.1.2",
"@vitest/pretty-format": "4.1.3",
"convert-source-map": "^2.0.0",
"tinyrainbow": "^3.1.0"
},
@@ -744,6 +761,9 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -765,6 +785,9 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -786,6 +809,9 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -807,6 +833,9 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -930,9 +959,9 @@
}
},
"node_modules/postcss": {
"version": "8.5.8",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz",
"integrity": "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==",
"version": "8.5.9",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.9.tgz",
"integrity": "sha512-7a70Nsot+EMX9fFU3064K/kdHWZqGVY+BADLyXc8Dfv+mTLLVl6JzJpPaCZ2kQL9gIJvKXSLMHhqdRRjwQeFtw==",
"dev": true,
"funding": [
{
@@ -959,14 +988,14 @@
}
},
"node_modules/rolldown": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.12.tgz",
"integrity": "sha512-yP4USLIMYrwpPHEFB5JGH1uxhcslv6/hL0OyvTuY+3qlOSJvZ7ntYnoWpehBxufkgN0cvXxppuTu5hHa/zPh+A==",
"version": "1.0.0-rc.13",
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.13.tgz",
"integrity": "sha512-bvVj8YJmf0rq4pSFmH7laLa6pYrhghv3PRzrCdRAr23g66zOKVJ4wkvFtgohtPLWmthgg8/rkaqRHrpUEh0Zbw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@oxc-project/types": "=0.122.0",
"@rolldown/pluginutils": "1.0.0-rc.12"
"@oxc-project/types": "=0.123.0",
"@rolldown/pluginutils": "1.0.0-rc.13"
},
"bin": {
"rolldown": "bin/cli.mjs"
@@ -975,21 +1004,21 @@
"node": "^20.19.0 || >=22.12.0"
},
"optionalDependencies": {
"@rolldown/binding-android-arm64": "1.0.0-rc.12",
"@rolldown/binding-darwin-arm64": "1.0.0-rc.12",
"@rolldown/binding-darwin-x64": "1.0.0-rc.12",
"@rolldown/binding-freebsd-x64": "1.0.0-rc.12",
"@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.12",
"@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.12",
"@rolldown/binding-linux-arm64-musl": "1.0.0-rc.12",
"@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.12",
"@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.12",
"@rolldown/binding-linux-x64-gnu": "1.0.0-rc.12",
"@rolldown/binding-linux-x64-musl": "1.0.0-rc.12",
"@rolldown/binding-openharmony-arm64": "1.0.0-rc.12",
"@rolldown/binding-wasm32-wasi": "1.0.0-rc.12",
"@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.12",
"@rolldown/binding-win32-x64-msvc": "1.0.0-rc.12"
"@rolldown/binding-android-arm64": "1.0.0-rc.13",
"@rolldown/binding-darwin-arm64": "1.0.0-rc.13",
"@rolldown/binding-darwin-x64": "1.0.0-rc.13",
"@rolldown/binding-freebsd-x64": "1.0.0-rc.13",
"@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.13",
"@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.13",
"@rolldown/binding-linux-arm64-musl": "1.0.0-rc.13",
"@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.13",
"@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.13",
"@rolldown/binding-linux-x64-gnu": "1.0.0-rc.13",
"@rolldown/binding-linux-x64-musl": "1.0.0-rc.13",
"@rolldown/binding-openharmony-arm64": "1.0.0-rc.13",
"@rolldown/binding-wasm32-wasi": "1.0.0-rc.13",
"@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.13",
"@rolldown/binding-win32-x64-msvc": "1.0.0-rc.13"
}
},
"node_modules/siginfo": {
@@ -1031,9 +1060,9 @@
"license": "MIT"
},
"node_modules/tinyexec": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.4.tgz",
"integrity": "sha512-u9r3uZC0bdpGOXtlxUIdwf9pkmvhqJdrVCH9fapQtgy/OeTTMZ1nqH7agtvEfmGui6e1XxjcdrlxvxJvc3sMqw==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.1.1.tgz",
"integrity": "sha512-VKS/ZaQhhkKFMANmAOhhXVoIfBXblQxGX1myCQ2faQrfmobMftXeJPcZGp0gS07ocvGJWDLZGyOZDadDBqYIJg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -1041,14 +1070,14 @@
}
},
"node_modules/tinyglobby": {
"version": "0.2.15",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",
"integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",
"version": "0.2.16",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz",
"integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==",
"dev": true,
"license": "MIT",
"dependencies": {
"fdir": "^6.5.0",
"picomatch": "^4.0.3"
"picomatch": "^4.0.4"
},
"engines": {
"node": ">=12.0.0"
@@ -1090,16 +1119,16 @@
}
},
"node_modules/vite": {
"version": "8.0.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.0.5.tgz",
"integrity": "sha512-nmu43Qvq9UopTRfMx2jOYW5l16pb3iDC1JH6yMuPkpVbzK0k+L7dfsEDH4jRgYFmsg0sTAqkojoZgzLMlwHsCQ==",
"version": "8.0.7",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.0.7.tgz",
"integrity": "sha512-P1PbweD+2/udplnThz3btF4cf6AgPky7kk23RtHUkJIU5BIxwPprhRGmOAHs6FTI7UiGbTNrgNP6jSYD6JaRnw==",
"dev": true,
"license": "MIT",
"dependencies": {
"lightningcss": "^1.32.0",
"picomatch": "^4.0.4",
"postcss": "^8.5.8",
"rolldown": "1.0.0-rc.12",
"rolldown": "1.0.0-rc.13",
"tinyglobby": "^0.2.15"
},
"bin": {
@@ -1168,19 +1197,19 @@
}
},
"node_modules/vitest": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.2.tgz",
"integrity": "sha512-xjR1dMTVHlFLh98JE3i/f/WePqJsah4A0FK9cc8Ehp9Udk0AZk6ccpIZhh1qJ/yxVWRZ+Q54ocnD8TXmkhspGg==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.3.tgz",
"integrity": "sha512-DBc4Tx0MPNsqb9isoyOq00lHftVx/KIU44QOm2q59npZyLUkENn8TMFsuzuO+4U2FUa9rgbbPt3udrP25GcjXw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/expect": "4.1.2",
"@vitest/mocker": "4.1.2",
"@vitest/pretty-format": "4.1.2",
"@vitest/runner": "4.1.2",
"@vitest/snapshot": "4.1.2",
"@vitest/spy": "4.1.2",
"@vitest/utils": "4.1.2",
"@vitest/expect": "4.1.3",
"@vitest/mocker": "4.1.3",
"@vitest/pretty-format": "4.1.3",
"@vitest/runner": "4.1.3",
"@vitest/snapshot": "4.1.3",
"@vitest/spy": "4.1.3",
"@vitest/utils": "4.1.3",
"es-module-lexer": "^2.0.0",
"expect-type": "^1.3.0",
"magic-string": "^0.30.21",
@@ -1208,10 +1237,12 @@
"@edge-runtime/vm": "*",
"@opentelemetry/api": "^1.9.0",
"@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0",
"@vitest/browser-playwright": "4.1.2",
"@vitest/browser-preview": "4.1.2",
"@vitest/browser-webdriverio": "4.1.2",
"@vitest/ui": "4.1.2",
"@vitest/browser-playwright": "4.1.3",
"@vitest/browser-preview": "4.1.3",
"@vitest/browser-webdriverio": "4.1.3",
"@vitest/coverage-istanbul": "4.1.3",
"@vitest/coverage-v8": "4.1.3",
"@vitest/ui": "4.1.3",
"happy-dom": "*",
"jsdom": "*",
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
@@ -1235,6 +1266,12 @@
"@vitest/browser-webdriverio": {
"optional": true
},
"@vitest/coverage-istanbul": {
"optional": true
},
"@vitest/coverage-v8": {
"optional": true
},
"@vitest/ui": {
"optional": true
},
+3 -231
View File
@@ -128,8 +128,6 @@ def _anthropic_event(
if "usage_input_tokens" in kwargs:
msg_usage = MagicMock()
msg_usage.input_tokens = kwargs.get("usage_input_tokens", 0)
msg_usage.cache_creation_input_tokens = 0
msg_usage.cache_read_input_tokens = 0
msg.usage = msg_usage
else:
msg.usage = None
@@ -178,217 +176,6 @@ class TestOpenAIProvider:
sanitize_messages([original])
assert original["content"] is None
# -- sanitize_messages: orphan detection -----------------------------------
def test_sanitize_orphaned_tool_call_synthesized(self) -> None:
"""Tool_call with no matching tool result gets a synthetic error result."""
msgs = [
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "bash", "arguments": "{}"},
},
],
},
{"role": "user", "content": "next"},
]
result = sanitize_messages(msgs)
assert len(result) == 3
assert result[1]["role"] == "tool"
assert result[1]["tool_call_id"] == "call_1"
assert "cancelled" in result[1]["content"]
assert result[2]["role"] == "user"
def test_sanitize_partial_results(self) -> None:
"""Only the missing tool_call gets a synthetic result."""
msgs = [
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "a", "arguments": "{}"},
},
{
"id": "call_2",
"type": "function",
"function": {"name": "b", "arguments": "{}"},
},
],
},
{"role": "tool", "tool_call_id": "call_1", "content": "ok"},
]
result = sanitize_messages(msgs)
assert len(result) == 3
assert result[1]["tool_call_id"] == "call_1"
assert result[1]["content"] == "ok"
assert result[2]["role"] == "tool"
assert result[2]["tool_call_id"] == "call_2"
assert "cancelled" in result[2]["content"]
def test_sanitize_complete_results_unchanged(self) -> None:
"""All tool_calls paired → no changes."""
msgs = [
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "a", "arguments": "{}"},
},
],
},
{"role": "tool", "tool_call_id": "call_1", "content": "ok"},
{"role": "user", "content": "thanks"},
]
result = sanitize_messages(msgs)
assert len(result) == 3
assert result[0]["tool_calls"][0]["id"] == "call_1"
assert result[1]["content"] == "ok"
assert result[2]["role"] == "user"
def test_sanitize_trailing_orphan(self) -> None:
"""Orphaned tool_call at end of conversation (no following messages)."""
msgs = [
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "a", "arguments": "{}"},
},
],
},
]
result = sanitize_messages(msgs)
assert len(result) == 2
assert result[1]["role"] == "tool"
assert result[1]["tool_call_id"] == "call_1"
def test_sanitize_orphaned_tool_result_dropped(self) -> None:
"""Tool result with no matching tool_call in preceding assistant → dropped."""
msgs = [
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "a", "arguments": "{}"},
},
],
},
{"role": "tool", "tool_call_id": "call_1", "content": "ok"},
{"role": "tool", "tool_call_id": "call_ORPHAN", "content": "stale"},
]
result = sanitize_messages(msgs)
assert len(result) == 2
assert result[1]["tool_call_id"] == "call_1"
def test_sanitize_empty_tool_call_id_filled(self) -> None:
"""Empty tool_call IDs get synthetic values; tool results are remapped to match."""
msgs = [
{
"role": "assistant",
"content": None,
"tool_calls": [
{"id": "", "type": "function", "function": {"name": "a", "arguments": "{}"}},
],
},
{"role": "tool", "tool_call_id": "", "content": "ok"},
]
result = sanitize_messages(msgs)
new_id = result[0]["tool_calls"][0]["id"]
assert new_id.startswith("call_")
assert len(new_id) > 10
# Tool result must have been remapped to match
assert result[1]["tool_call_id"] == new_id
# No synthetic result needed — the pairing is complete
assert len(result) == 2
def test_sanitize_stale_result_with_orphan(self) -> None:
"""Stale tool results are dropped even when orphaned calls are present."""
msgs = [
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "a", "arguments": "{}"},
},
{
"id": "call_2",
"type": "function",
"function": {"name": "b", "arguments": "{}"},
},
],
},
{"role": "tool", "tool_call_id": "call_1", "content": "ok"},
{"role": "tool", "tool_call_id": "call_STALE", "content": "stale"},
]
result = sanitize_messages(msgs)
result_tc_ids = [m["tool_call_id"] for m in result if m.get("role") == "tool"]
assert "call_STALE" not in result_tc_ids
assert "call_1" in result_tc_ids
assert "call_2" in result_tc_ids # synthesized
def test_sanitize_orphan_no_mutation(self) -> None:
"""Original messages and dicts are not mutated by orphan detection."""
tc = {"id": "", "type": "function", "function": {"name": "a", "arguments": "{}"}}
msg = {"role": "assistant", "content": None, "tool_calls": [tc]}
sanitize_messages([msg])
assert tc["id"] == "" # original dict untouched
assert msg["tool_calls"][0]["id"] == ""
def test_sanitize_repeated_ids_across_turns(self) -> None:
"""Reused tool_call IDs across turns are handled per-turn, not globally."""
msgs = [
# Turn 1: call_1 fully paired
{"role": "user", "content": "do A"},
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "a", "arguments": "{}"},
},
],
},
{"role": "tool", "tool_call_id": "call_1", "content": "ok"},
# Turn 2: reuses call_1 but has no result → must be synthesized
{"role": "user", "content": "do B"},
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "b", "arguments": "{}"},
},
],
},
]
result = sanitize_messages(msgs)
# Turn 2's orphaned call_1 should get a synthetic result
tool_msgs = [m for m in result if m.get("role") == "tool"]
assert len(tool_msgs) == 2 # one real from turn 1, one synthetic from turn 2
# -- convert_tools --------------------------------------------------------
def test_convert_tools_passthrough(self) -> None:
@@ -850,8 +637,6 @@ class TestAnthropicProvider:
response.usage = MagicMock()
response.usage.input_tokens = 10
response.usage.output_tokens = 5
response.usage.cache_creation_input_tokens = 0
response.usage.cache_read_input_tokens = 0
client = MagicMock()
stream_ctx = MagicMock()
@@ -888,8 +673,6 @@ class TestAnthropicProvider:
response.usage = MagicMock()
response.usage.input_tokens = 15
response.usage.output_tokens = 20
response.usage.cache_creation_input_tokens = 0
response.usage.cache_read_input_tokens = 0
client = MagicMock()
stream_ctx = MagicMock()
@@ -925,8 +708,6 @@ class TestAnthropicProvider:
response.usage = MagicMock()
response.usage.input_tokens = 100
response.usage.output_tokens = 50
response.usage.cache_creation_input_tokens = 0
response.usage.cache_read_input_tokens = 0
client = MagicMock()
stream_ctx = MagicMock()
@@ -2129,8 +1910,6 @@ class TestAnthropicWebSearch:
response.stop_reason = "end_turn"
response.usage.input_tokens = 100
response.usage.output_tokens = 50
response.usage.cache_creation_input_tokens = 0
response.usage.cache_read_input_tokens = 0
client = MagicMock()
stream_ctx = MagicMock()
@@ -3097,8 +2876,7 @@ class TestAnthropicPromptCaching:
messages=[{"role": "user", "content": "hi"}],
)
)
# prompt_tokens = input_tokens (100) + cache_creation (80) + cache_read (0) = 180
start_chunks = [r for r in results if r.usage is not None and r.usage.prompt_tokens == 180]
start_chunks = [r for r in results if r.usage is not None and r.usage.prompt_tokens == 100]
assert len(start_chunks) == 1
assert start_chunks[0].usage is not None
assert start_chunks[0].usage.cache_creation_tokens == 80
@@ -3446,14 +3224,11 @@ class TestResponsesMessageConversion:
},
]
_, items = self.provider._convert_messages(messages)
# sanitize_messages synthesizes a missing tool result for the orphaned call
assert len(items) == 2
assert len(items) == 1
assert items[0]["type"] == "function_call"
assert items[0]["call_id"] == "call_1"
assert items[0]["name"] == "read_file"
assert items[0]["arguments"] == '{"path": "/tmp"}'
assert items[1]["type"] == "function_call_output"
assert items[1]["call_id"] == "call_1"
def test_tool_result(self) -> None:
messages = [
@@ -3504,14 +3279,11 @@ class TestResponsesMessageConversion:
},
]
_, items = self.provider._convert_messages(messages)
# sanitize_messages synthesizes a missing tool result for the orphaned call
assert len(items) == 3
assert len(items) == 2
assert items[0]["type"] == "message"
assert items[0]["content"] == "I'll read that file"
assert items[1]["type"] == "function_call"
assert items[1]["name"] == "read_file"
assert items[2]["type"] == "function_call_output"
assert items[2]["call_id"] == "call_1"
class TestResponsesToolConversion:
+4 -6
View File
@@ -105,8 +105,7 @@ class TestChatSessionConstruction:
def test_msg_char_count_content_only(self, tmp_db):
session = _make_session()
msg = {"role": "assistant", "content": "hello world"}
# "hello world" (11) + "assistant" (9) = 20
assert session._msg_char_count(msg) == 20
assert session._msg_char_count(msg) == 11
def test_msg_char_count_with_tool_calls(self, tmp_db):
session = _make_session()
@@ -123,14 +122,13 @@ class TestChatSessionConstruction:
}
],
}
# "hi" (2) + "tc_1" (4) + "bash" (4) + '{"command": "ls"}' (17) + "assistant" (9) = 36
assert session._msg_char_count(msg) == 36
# "hi" (2) + "bash" (4) + '{"command": "ls"}' (17) = 23
assert session._msg_char_count(msg) == 23
def test_msg_char_count_none_content(self, tmp_db):
session = _make_session()
msg = {"role": "assistant", "content": None}
# len("assistant") = 9
assert session._msg_char_count(msg) == 9
assert session._msg_char_count(msg) == 0
def test_reasoning_effort_stored(self, tmp_db):
session = _make_session(reasoning_effort="high")
+1 -1
View File
@@ -1,3 +1,3 @@
"""turnstone - Multi-node AI orchestration platform with tool use, agent routing, and cluster simulation."""
__version__ = "1.2.2"
__version__ = "1.3.0a2"
+16 -30
View File
@@ -714,19 +714,14 @@ class AnthropicProvider:
elif event_type == "message_delta":
if hasattr(event, "usage") and event.usage:
u = event.usage
inp = getattr(u, "input_tokens", 0) or 0
out = getattr(u, "output_tokens", 0) or 0
cc = getattr(u, "cache_creation_input_tokens", 0) or 0
cr = getattr(u, "cache_read_input_tokens", 0) or 0
# prompt_tokens = total input (non-cached + cached) so
# context-window tracking matches OpenAI semantics.
total_input = inp + cc + cr
sc.usage = UsageInfo(
prompt_tokens=total_input,
completion_tokens=out,
total_tokens=total_input + out,
cache_creation_tokens=cc,
cache_read_tokens=cr,
prompt_tokens=getattr(u, "input_tokens", 0),
completion_tokens=getattr(u, "output_tokens", 0),
total_tokens=(
getattr(u, "input_tokens", 0) + getattr(u, "output_tokens", 0)
),
cache_creation_tokens=getattr(u, "cache_creation_input_tokens", 0) or 0,
cache_read_tokens=getattr(u, "cache_read_input_tokens", 0) or 0,
)
if hasattr(event.delta, "stop_reason") and event.delta.stop_reason:
sc.finish_reason = _normalize_finish_reason(event.delta.stop_reason)
@@ -737,16 +732,12 @@ class AnthropicProvider:
elif event_type == "message_start":
if hasattr(event.message, "usage") and event.message.usage:
u = event.message.usage
inp = getattr(u, "input_tokens", 0) or 0
cc = getattr(u, "cache_creation_input_tokens", 0) or 0
cr = getattr(u, "cache_read_input_tokens", 0) or 0
total_input = inp + cc + cr
sc.usage = UsageInfo(
prompt_tokens=total_input,
prompt_tokens=getattr(u, "input_tokens", 0),
completion_tokens=0,
total_tokens=total_input,
cache_creation_tokens=cc,
cache_read_tokens=cr,
total_tokens=getattr(u, "input_tokens", 0),
cache_creation_tokens=getattr(u, "cache_creation_input_tokens", 0) or 0,
cache_read_tokens=getattr(u, "cache_read_input_tokens", 0) or 0,
)
has_content = sc.content_delta or sc.reasoning_delta or sc.tool_call_deltas
@@ -835,17 +826,12 @@ class AnthropicProvider:
usage = None
if hasattr(response, "usage") and response.usage:
u = response.usage
inp = getattr(u, "input_tokens", 0) or 0
out = getattr(u, "output_tokens", 0) or 0
cc = getattr(u, "cache_creation_input_tokens", 0) or 0
cr = getattr(u, "cache_read_input_tokens", 0) or 0
total_input = inp + cc + cr
usage = UsageInfo(
prompt_tokens=total_input,
completion_tokens=out,
total_tokens=total_input + out,
cache_creation_tokens=cc,
cache_read_tokens=cr,
prompt_tokens=u.input_tokens,
completion_tokens=u.output_tokens,
total_tokens=u.input_tokens + u.output_tokens,
cache_creation_tokens=getattr(u, "cache_creation_input_tokens", 0) or 0,
cache_read_tokens=getattr(u, "cache_read_input_tokens", 0) or 0,
)
return CompletionResult(
+10 -126
View File
@@ -7,19 +7,14 @@ formatting, and message sanitisation live here so both
from __future__ import annotations
import uuid
from typing import Any
import structlog
from turnstone.core.providers._protocol import (
ModelCapabilities,
UsageInfo,
_lookup_capabilities,
)
log = structlog.get_logger(__name__)
# ---------------------------------------------------------------------------
# Model capability table
# ---------------------------------------------------------------------------
@@ -309,132 +304,21 @@ def format_citations(content: str, annotations: list[Any]) -> str:
def sanitize_messages(
messages: list[dict[str, Any]],
) -> list[dict[str, Any]]:
"""Sanitize messages for OpenAI-compatible APIs.
"""Ensure assistant messages always have ``content`` or ``tool_calls``.
Performs three repairs:
1. Ensures assistant messages always have ``content`` or ``tool_calls``
(APIs reject messages with neither).
2. Fills empty tool_call IDs with synthetic ``call_{uuid}`` values
(local servers sometimes omit them).
3. Detects and repairs orphaned tool_call / tool_result pairs:
- Synthesizes error tool messages for tool_calls with no matching
tool result.
- Drops tool messages whose ``tool_call_id`` has no matching
tool_call in the preceding assistant message.
Returns a new list; the original messages are not mutated.
OpenAI-compatible APIs reject assistant messages that have neither.
This is a defensive catch-all; the upstream layers should already
guarantee well-formed messages.
"""
out: list[dict[str, Any]] = []
i = 0
while i < len(messages):
msg = messages[i]
role = msg.get("role", "")
# (1) Fix empty-content assistant messages
if role == "assistant" and msg.get("content") is None and not msg.get("tool_calls"):
for msg in messages:
if (
msg.get("role") == "assistant"
and msg.get("content") is None
and not msg.get("tool_calls")
):
msg = {**msg, "content": ""}
out.append(msg)
i += 1
continue
# (2+3) Assistant with tool_calls: fix IDs and detect orphans
if role == "assistant" and msg.get("tool_calls"):
tool_calls = msg["tool_calls"]
# Back-fill empty IDs and build positional remap for tool results.
# Local servers (vLLM, llama.cpp) sometimes omit IDs entirely;
# positional pairing is the best heuristic in that case.
needs_id_fix = any(not tc.get("id") for tc in tool_calls)
id_remap: dict[int, str] = {} # positional index → new ID
if needs_id_fix:
new_tcs = []
empty_idx = 0
for tc in tool_calls:
if not tc.get("id"):
new_id = f"call_{uuid.uuid4().hex}"
id_remap[empty_idx] = new_id
empty_idx += 1
new_tcs.append({**tc, "id": new_id})
else:
new_tcs.append(tc)
msg = {**msg, "tool_calls": new_tcs}
tool_calls = msg["tool_calls"]
# Collect IDs from this assistant message
tc_ids = [tc["id"] for tc in tool_calls if tc.get("id")]
tc_id_set = set(tc_ids)
out.append(msg)
i += 1
# Copy through existing tool messages, applying ID remap and
# filtering out stale results that don't match any tool_call.
local_answered: set[str] = set()
empty_result_idx = 0
while i < len(messages) and messages[i].get("role") == "tool":
tool_msg = messages[i]
result_tc_id = tool_msg.get("tool_call_id", "")
if not result_tc_id and empty_result_idx in id_remap:
# Positional remap: empty result → matching new ID
new_id = id_remap[empty_result_idx]
tool_msg = {**tool_msg, "tool_call_id": new_id}
local_answered.add(new_id)
empty_result_idx += 1
out.append(tool_msg)
elif not result_tc_id:
# Empty ID with no remap available — drop it
log.debug("sanitize_messages: dropping tool result with empty ID")
empty_result_idx += 1
elif result_tc_id in tc_id_set:
local_answered.add(result_tc_id)
out.append(tool_msg)
else:
log.debug(
"sanitize_messages: dropping stale tool result: %s",
result_tc_id,
)
i += 1
# Synthesize error results for tool_calls not answered in
# THIS turn (not all of `out`, to avoid false matches from
# reused IDs across turns).
still_orphaned = [uid for uid in tc_ids if uid not in local_answered]
if still_orphaned:
log.debug(
"sanitize_messages: synthesizing %d tool result(s) for orphaned tool_calls",
len(still_orphaned),
)
for uid in still_orphaned:
out.append(
{
"role": "tool",
"tool_call_id": uid,
"content": "Tool execution was cancelled.",
}
)
continue
# (3d) Drop orphaned tool results
if role == "tool":
tc_id = msg.get("tool_call_id", "")
# Find the preceding assistant message's tool_call IDs
prev_tc_ids: set[str] = set()
for k in range(len(out) - 1, -1, -1):
if out[k].get("role") == "assistant" and out[k].get("tool_calls"):
prev_tc_ids = {tc.get("id", "") for tc in out[k]["tool_calls"] if tc.get("id")}
break
if prev_tc_ids and tc_id and tc_id not in prev_tc_ids:
log.debug(
"sanitize_messages: dropping orphaned tool result (no matching tool_call): %s",
tc_id,
)
i += 1
continue
out.append(msg)
i += 1
return out
@@ -24,7 +24,6 @@ from turnstone.core.providers._openai_common import (
format_citations,
lookup_openai_capabilities,
resolve_reasoning_effort,
sanitize_messages,
)
from turnstone.core.providers._protocol import (
CompletionResult,
@@ -84,7 +83,6 @@ class OpenAIResponsesProvider:
concatenated system/developer messages (or ``None``) and *input_items*
is the Responses API ``input`` array.
"""
messages = sanitize_messages(messages)
instructions_parts: list[str] = []
items: list[dict[str, Any]] = []
+9 -92
View File
@@ -372,7 +372,6 @@ class ChatSession:
self._applied_skill_version: int = 0
self._applied_skill_content: str = "" # inline prompt from applied skill
self._assistant_pending_tokens = 0
self._calibrated_msg_count = 0 # len(messages) at last _update_token_table
self.creative_mode = False
self._notify_count = 0
# Watch support: server-level runner injected via set_watch_runner()
@@ -919,25 +918,11 @@ class ChatSession:
def _remaining_token_budget(self) -> int:
"""Estimate how many tokens are available for new content.
When provider-reported usage is available, uses the last API
call's ``prompt_tokens`` as ground truth and only estimates the
delta (messages added since that call). Falls back to pure
local estimates otherwise.
Reserves a response budget (capped at 25% of context window, since
``max_tokens`` is an upper bound, not guaranteed consumption) plus
a 5% safety margin. Returns at least 0.
"""
used = self._system_tokens + sum(self._msg_tokens)
if self._last_usage:
# Provider-reported tokens from the last API call
base = self._last_usage["prompt_tokens"]
# Only estimate tokens for messages added AFTER calibration.
# Clamp index to prevent stale _calibrated_msg_count from
# over-slicing after compaction or message list mutations.
start = min(self._calibrated_msg_count, len(self._msg_tokens))
new_msg_tokens = sum(self._msg_tokens[start:])
used = base + new_msg_tokens
response_reserve = min(self.max_tokens, self.context_window // 4)
safety_margin = int(self.context_window * 0.05)
return max(0, self.context_window - used - response_reserve - safety_margin)
@@ -1105,7 +1090,6 @@ class ChatSession:
self._read_files.clear()
self._recent_tool_sigs.clear()
self._last_usage = None
self._calibrated_msg_count = 0
self._title_generated = True # don't re-title resumed workstreams
self._msg_tokens = [
max(1, int(self._msg_char_count(m) / self._chars_per_token)) for m in self.messages
@@ -1852,7 +1836,6 @@ class ChatSession:
return
self._update_token_table(assistant_msg)
self._print_status_line() # Report usage for EVERY API call
self.messages.append(assistant_msg)
self._msg_tokens.append(
self._assistant_pending_tokens
@@ -1892,6 +1875,7 @@ class ChatSession:
tool_calls = assistant_msg.get("tool_calls")
if not tool_calls:
self._print_status_line()
# Auto-compact when prompt exceeds threshold
if (
self._last_usage
@@ -2109,18 +2093,6 @@ class ChatSession:
if user_feedback:
self.messages.append({"role": "user", "content": user_feedback})
self._msg_tokens.append(max(1, int(len(user_feedback) / self._chars_per_token)))
# Mid-turn compaction: prevent context overflow during long
# tool chains. Uses local estimates since _last_usage reflects
# the previous API call, not the tool results just appended.
estimated_prompt = self._system_tokens + sum(self._msg_tokens)
if estimated_prompt > self.context_window * self.auto_compact_pct:
pct_display = int(self.auto_compact_pct * 100)
self.ui.on_info(
f"\n[Auto-compacting mid-turn: estimated prompt "
f"exceeds {pct_display}% of context window]"
)
self._compact_messages(auto=True)
except GenerationCancelled:
# If a newer send() has started (force cancel), this thread is
# orphaned — skip all message mutations and state changes.
@@ -2287,11 +2259,6 @@ class ChatSession:
Returns the complete assistant message as a dict suitable for
appending to self.messages.
"""
# Reset so this API call captures fresh usage — prevents stale
# completion_tokens from a prior tool-chain iteration leaking
# through the max() accumulator.
self._last_usage = None
content_parts: list[str] = []
reasoning_parts: list[str] = []
tool_calls_acc: dict[int, dict[str, Any]] = {}
@@ -2631,44 +2598,17 @@ class ChatSession:
# -- Token tracking & status ----------------------------------------------
# Fixed token count per image (provider-agnostic average).
_IMAGE_TOKENS = 1000
@staticmethod
def _msg_text_chars(msg: dict[str, Any]) -> tuple[int, int]:
"""Return (text_chars, image_count) for a message.
Counts all textual content plus structural overhead (role,
tool_call IDs, tool call names/arguments). Images are counted
separately so the calibration can subtract their fixed token
cost from prompt_tokens.
"""
def _msg_char_count(self, msg: dict[str, Any]) -> int:
"""Count characters in a message, including tool call arguments."""
content = msg.get("content")
n = 0
images = 0
if isinstance(content, list):
n += sum(len(p.get("text", "")) for p in content if p.get("type") == "text")
images += sum(1 for p in content if p.get("type") == "image_url")
n = sum(len(p.get("text", "")) for p in content if p.get("type") == "text")
else:
n += len(content or "")
n = len(content or "")
for tc in msg.get("tool_calls", []):
n += len(tc.get("id", ""))
n += len(tc.get("function", {}).get("name", ""))
n += len(tc.get("function", {}).get("arguments", ""))
# Structural overhead: role, tool_call_id
n += len(msg.get("role", ""))
n += len(msg.get("tool_call_id", ""))
return n, images
def _msg_char_count(self, msg: dict[str, Any]) -> int:
"""Count characters in a message, including structural overhead.
Includes role markers, tool_call IDs, and image placeholders so
that the chars_per_token calibration matches what providers
actually bill.
"""
text_chars, images = self._msg_text_chars(msg)
return text_chars + int(images * self._IMAGE_TOKENS * self._chars_per_token)
return n
def _update_token_table(self, assistant_msg: dict[str, Any]) -> None:
"""Update per-message token estimates using API usage data."""
@@ -2679,28 +2619,12 @@ class ChatSession:
compl_tok = self._last_usage["completion_tokens"]
# Calibrate chars_per_token ratio from actual usage.
# Images get a fixed token budget, so we subtract those from the
# provider-reported prompt_tokens and calibrate only the text portion.
all_msgs = self._full_messages() # system + self.messages (before append)
active_tools = self._get_active_tools() or []
tool_def_chars = sum(len(json.dumps(t)) for t in active_tools)
text_chars = 0
image_count = 0
for m in all_msgs:
tc, ic = self._msg_text_chars(m)
text_chars += tc
image_count += ic
text_chars += tool_def_chars
image_tokens = image_count * self._IMAGE_TOKENS
text_prompt_tok = prompt_tok - image_tokens
if text_prompt_tok <= 0:
log.debug(
"Image token estimate (%d) >= prompt_tokens (%d), skipping calibration",
image_tokens,
prompt_tok,
)
elif text_chars > 0:
self._chars_per_token = text_chars / text_prompt_tok
total_chars = sum(self._msg_char_count(m) for m in all_msgs) + tool_def_chars
if total_chars > 0 and prompt_tok > 0:
self._chars_per_token = total_chars / prompt_tok
# Compute system_tokens (stable after first call)
sys_chars = sum(self._msg_char_count(m) for m in self.system_messages)
@@ -2714,10 +2638,6 @@ class ChatSession:
# Stash completion_tokens for the assistant message about to be appended
self._assistant_pending_tokens = compl_tok
# Record how many messages were in context at calibration time so
# _remaining_token_budget() can estimate only the delta.
self._calibrated_msg_count = len(self.messages)
# Token budget tracking
if self._token_budget > 0:
total = prompt_tok + compl_tok
@@ -2929,7 +2849,6 @@ class ChatSession:
su_tok = max(1, int(self._msg_char_count(summary_user) / self._chars_per_token))
sa_tok = max(1, int(self._msg_char_count(summary_asst) / self._chars_per_token))
self._msg_tokens = [su_tok, sa_tok]
self._calibrated_msg_count = len(self.messages) # anchored to compacted state
after_tokens = self._system_tokens + sum(self._msg_tokens)
# Update usage estimate so the status bar reflects post-compaction state
@@ -6794,7 +6713,6 @@ class ChatSession:
self._read_files.clear()
self._recent_tool_sigs.clear()
self._last_usage = None
self._calibrated_msg_count = 0
self._msg_tokens = []
self.ui.on_info("Context cleared (messages preserved in database).")
@@ -6805,7 +6723,6 @@ class ChatSession:
self._read_files.clear()
self._recent_tool_sigs.clear()
self._last_usage = None
self._calibrated_msg_count = 0
self._msg_tokens = []
self._ws_id = uuid.uuid4().hex
self._title_generated = False
Generated
+1 -1
View File
@@ -2501,7 +2501,7 @@ wheels = [
[[package]]
name = "turnstone"
version = "1.2.2"
version = "1.3.0a2"
source = { editable = "." }
dependencies = [
{ name = "alembic" },