fix(telegram): summarise tool results instead of quoting an arbitrary line
Operator report: tool output in the Telegram channel was unreadable during
search-heavy turns -- a wall of fenced blocks each showing one arbitrary
match line ("/path/config.json-322- }") under a heading that said
only "grep -- done".
The renderer quoted the first non-module-cache line of a result and appended
a line count recomputed from its own truncated sample, which could not agree
with the total the tool had already reported: one search rendered the tool's
"194 more lines" beside our "… 3 more lines". Two different numbers for one
result set read as noise, and the quoted line carried no context at all.
- Describe, don't quote: a search is reported as "N matches", a truncated
result as "<total> lines total; showing <n>", and every other tool falls
back to its first informative line. Truncation notices are skipped, since
they are metadata rather than content.
- Never invent a count: the tool's own reported total is the only
trustworthy source, parsed from its truncation notice rather than
recomputed from the visible sample.
- Remove the now-dead compactToolPreview and countNonEmptyOrContentLines.
Also bump go-telegram/bot v1.25.0 -> v1.27.0, which fixes a streaming bug
that lands squarely on this path: rawRequest sent the multipart body through
an io.Pipe, which net/http cannot replay, so sendMessage/editMessageText
failed until the connection was dropped.
Remaining work from the report (collapsing repeated calls into one counted
entry, and a ring of recent activity lines with a capped frame) is tracked
in #837.
This commit is contained in:
1 parent
b250dc47d1
commit
72bc95cc00
5 files changed
+269
-59
No files matched your search
@@ -68,7 +68,7 @@ require (
|
||||
github.com/BurntSushi/toml v1.6.0
|
||||
github.com/go-git/go-billy/v6 v6.0.0-alpha.2
|
||||
github.com/go-git/go-git/v6 v6.0.0-alpha.5
|
||||
github.com/go-telegram/bot v1.25.0
|
||||
github.com/go-telegram/bot v1.27.0
|
||||
github.com/google/codesearch v1.3.0-rc.1
|
||||
github.com/google/go-github/v78 v78.0.0
|
||||
github.com/google/uuid v1.6.0
|
||||
|
||||
@@ -2,21 +2,16 @@ cel.dev/cel-go v0.32.0 h1:irvpFKr5EuGPyxeME03ERh0rii1TX+BDAnB9eL3IvNk=
|
||||
cel.dev/cel-go v0.32.0/go.mod h1:DnVip7tpJSsgZymwfT+m1tnEVy3ivAjSMXPx12YrMkU=
|
||||
cel.dev/expr v0.25.3 h1:A2jO8jwOugrrovveCWfj0KEZOfqiLgAcwjpHPhzIGw0=
|
||||
cel.dev/expr v0.25.3/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
|
||||
cloud.google.com/go/auth v0.18.2/go.mod h1:xD+oY7gcahcu7G2SG2DsBerfFxgPAJz17zz2joOFF3M=
|
||||
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
|
||||
code.gitea.io/sdk/gitea v0.25.1 h1:yywxWwoV+SdjHtbC6unBiXojWdZOtoHuGhEazEXeWuE=
|
||||
code.gitea.io/sdk/gitea v0.25.1/go.mod h1:uDFWYBU8dgZsgOHwe6C/6olxvf8FHguNB3wW1i83fgg=
|
||||
github.com/42wim/httpsig v1.2.4 h1:mI5bH0nm4xn7K18fo1K3okNDRq8CCJ0KbBYWyA6r8lU=
|
||||
github.com/42wim/httpsig v1.2.4/go.mod h1:yKsYfSyTBEohkPik224QPFylmzEBtda/kjyIAJjh3ps=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.33.0/go.mod h1:pJTkW8hEUIIi3Pf65lPZOnn4Y81yCllX6IWk2jNXdkM=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM=
|
||||
github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo=
|
||||
github.com/a-h/templ v0.3.1020/go.mod h1:A2DlK61v+K+NRoGnhmYbNYVmtYHcFO5/AisMvBdDxTM=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.8.0 h1:bVV5ZAuwaREn4klRSJusYaA+A7NXq8Qi9C/knCaQ2N4=
|
||||
@@ -25,18 +20,14 @@ github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYW
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/bwesterb/go-ristretto v1.2.4/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cloudflare/circl v1.6.5 h1:O64F26HEqNhznd/hrC5KZXVKYuKM2rx4deZDTc4ihQA=
|
||||
github.com/cloudflare/circl v1.6.5/go.mod h1:h5LNyxAc5nTue9DS5jT+48en2PSDYt3zdGnz5OstK6c=
|
||||
github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2/go.mod h1:qwXFYgsP6T7XnJtbKlf1HP8AjxZZyzxMmc+Lq5GjlU4=
|
||||
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
|
||||
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
|
||||
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
|
||||
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
|
||||
github.com/containerd/typeurl/v2 v2.2.0/go.mod h1:8XOOxnyatxSWuG8OfsZXVnAF4iZfedjS/8UHSPJnX4g=
|
||||
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
|
||||
@@ -51,10 +42,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/envoyproxy/go-control-plane v0.14.0/go.mod h1:NcS5X47pLl/hfqxU70yPwL9ZMkUlwlKxtAohpi2wBEU=
|
||||
github.com/envoyproxy/go-control-plane/envoy v1.37.0/go.mod h1:DReE9MMrmecPy+YvQOAOHNYMALuowAnbjjEMkkWOi6A=
|
||||
github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.3.3/go.mod h1:TsndJ/ngyIdQRhMcVVGDDHINPLWB7C82oDArY51KfB0=
|
||||
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
|
||||
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
|
||||
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
|
||||
@@ -69,17 +56,13 @@ github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1 h1:gmqi2jvsreu0s8JMLylYDFq4s
|
||||
github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1/go.mod h1:ECf1MqJlBdYpKggBrOXjo/0EnvRZx6D++I86UYjPgAQ=
|
||||
github.com/go-git/go-git/v6 v6.0.0-alpha.5 h1:sE+OlkHgYWNMVmN1s9sR7uyFgsWLtxcNWse/vBYKxRE=
|
||||
github.com/go-git/go-git/v6 v6.0.0-alpha.5/go.mod h1:3IjhiZnM+uBmUrOGSeqrJpsmi4Vd0H2NZO/uK2a7d0s=
|
||||
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
|
||||
github.com/go-telegram/bot v1.25.0 h1:C072msZtr+GjJiQsX/UJLirz+jzSNZVWkckxWufR7Ww=
|
||||
github.com/go-telegram/bot v1.25.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/glog v1.2.5/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
|
||||
github.com/go-telegram/bot v1.27.0 h1:PG9yBDzM8O26oUerE9SZwWlHon4RpH8WcNslZ7CEZmE=
|
||||
github.com/go-telegram/bot v1.27.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/codesearch v1.3.0-rc.1 h1:vSFGuF5wS3sjimuLzqPG+PGjWQ9VvEtPFbxdZD7YuuQ=
|
||||
@@ -93,14 +76,10 @@ github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfh
|
||||
github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU=
|
||||
github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
|
||||
github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
|
||||
github.com/google/go-tpm-tools v0.3.13-0.20230620182252-4639ecce2aba/go.mod h1:EFYHy8/1y2KfgTAsx7Luu7NGhoxtuVHnNo8jE7FikKc=
|
||||
github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo=
|
||||
github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=
|
||||
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.11/go.mod h1:RFV7MUdlb7AgEq2v7FmMCfeSMCllAzWxFgRdusoGks8=
|
||||
github.com/googleapis/gax-go/v2 v2.17.0/go.mod h1:mzaqghpQp4JDh3HvADwrat+6M3MOIDp5YKHhb9PAgDY=
|
||||
github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA=
|
||||
github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
@@ -128,7 +107,6 @@ github.com/moby/moby/api v1.56.0 h1:GQzua3NA599ASSIICx0iFgiJeO9YkdDARvQsm23ZZuQ=
|
||||
github.com/moby/moby/api v1.56.0/go.mod h1:sZ+THbVWkjOmBPPfbnzdD/G1LuIexWhqlSHHPTDQ1Uk=
|
||||
github.com/moby/moby/client v0.6.0 h1:AJjEB21QPbXSXjDsZorFBoDZPhMrfbpaPLgSMAW9Bgs=
|
||||
github.com/moby/moby/client v0.6.0/go.mod h1:OCo00wNRyA3m4lmJ228W3JbyCN4ZNNYjpOXiJydBdcQ=
|
||||
github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc=
|
||||
github.com/nats-io/jwt/v2 v2.8.2 h1:XXRgB60MSTnqsRwejQurVDs/hcv2dkt+86GjI+I/bMc=
|
||||
github.com/nats-io/jwt/v2 v2.8.2/go.mod h1:Ag/56sq9OblL4JgdYufDd16Egb17Kr/8WwwuO/forVc=
|
||||
github.com/nats-io/nats-server/v2 v2.14.6 h1:dHjEHa49lUTxIb5jrsk5kz/AmOyOQ4T9ti8djcBumDQ=
|
||||
@@ -149,20 +127,15 @@ github.com/pjbgf/sha1cd v0.6.0 h1:3WJ8Wz8gvDz29quX1OcEmkAlUg9diU4GxJHqs0/XiwU=
|
||||
github.com/pjbgf/sha1cd v0.6.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
|
||||
github.com/samcharles93/ai-sdk v0.1.32 h1:rfBpWUOADuRTaq2kyCnMjdhtlFfaqUbsyL5DbIluqmA=
|
||||
github.com/samcharles93/ai-sdk v0.1.32/go.mod h1:u4zrQ9/Q58L5mNEut4bNQ1ks+RCKq71LN5EDz2N/0Zk=
|
||||
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
|
||||
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
|
||||
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spiffe/go-spiffe/v2 v2.7.0/go.mod h1:47Q0Q9/AqGha8QLHp+kxpH4Wca7X7EnOtlIJy3mxZ3U=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
|
||||
@@ -171,7 +144,6 @@ github.com/traefik/yaegi v0.16.1 h1:f1De3DVJqIDKmnasUF6MwmWv1dSEEat0wcpXhD2On3E=
|
||||
github.com/traefik/yaegi v0.16.1/go.mod h1:4eVhbPb3LnD2VigQjhYbEJ69vDRFdT2HQNrXx8eEwUY=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/contrib/detectors/gcp v1.44.0/go.mod h1:tNAsgd8avTGke1+MndXlU5Cru4PQ9Ai/cCNWQv/ZJ/s=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 h1:3g7B90UzBltIDKq1/5mrTGxTnOFDV0ICOhLoxiZ8jlg=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0/go.mod h1:Ef8SuTh59BT7+ofpDxN9z+yOlc4t2GjLmKDgYNJL/NU=
|
||||
go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc=
|
||||
@@ -199,7 +171,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
|
||||
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
|
||||
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -221,8 +192,6 @@ golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
|
||||
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
|
||||
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
|
||||
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260904194346-d0f1323225a4 h1:NCe/UiklGd/9xjT+ROBVhJ1kf6TRQaFedsR+z7u1gvo=
|
||||
|
||||
@@ -230,7 +230,10 @@ func TestLiveReplyRendersNoisyToolTurnAsCompactTelegramText(t *testing.T) {
|
||||
live.finalize(context.Background(), "I found the relevant renderer and stopped after the output-volume cap.")
|
||||
|
||||
got := (*calls)[len(*calls)-1].body()
|
||||
want := "🔧 read — done\n\npackage gateway\n… 7 more lines\n\n" +
|
||||
// A tool result is described, never quoted with an invented line count:
|
||||
// "… 7 more lines" was the renderer counting its own truncated sample, and
|
||||
// it cannot agree with the total the tool actually reported.
|
||||
want := "🔧 read — done\n\npackage gateway\n\n" +
|
||||
"🔧 find — done\n\n/home/sam/projects/unrelated/main.go\n\n" +
|
||||
"🔧 shell — failed\n\ncommand_exit: exit status 2\n\n" +
|
||||
"🔧 tools — stopped ×5\n\ntool-output limit reached (200000 chars); further results suppressed\n\n" +
|
||||
@@ -238,6 +241,9 @@ func TestLiveReplyRendersNoisyToolTurnAsCompactTelegramText(t *testing.T) {
|
||||
if got != want {
|
||||
t.Fatalf("Telegram-visible text:\n%s\n\nwant:\n%s", got, want)
|
||||
}
|
||||
if strings.Contains(got, "more lines") {
|
||||
t.Errorf("renderer invented a line count from a truncated sample:\n%s", got)
|
||||
}
|
||||
for i, call := range *calls {
|
||||
for _, forbidden := range []string{
|
||||
`\\n`, `\\\"`, "[string]", "turn budget exceeded",
|
||||
@@ -704,9 +710,15 @@ func TestLiveReplyFramedTextClampsAnOversizedToolBlock(t *testing.T) {
|
||||
if !strings.Contains(last.body(), "the answer") {
|
||||
t.Fatalf("answer was lost after bounding oversized tool output: %.80q…", last.body())
|
||||
}
|
||||
if strings.Count(last.body(), "ok") > 3 || !strings.Contains(last.body(), "more lines") {
|
||||
// The oversized block must be summarised rather than dumped, and the
|
||||
// summary must not be a line count the renderer invented: "ok" repeats far
|
||||
// more than three times, so anything that echoed the sample fails here.
|
||||
if strings.Count(last.body(), "ok") > 3 {
|
||||
t.Fatalf("oversized tool output was not summarized: %.80q…", last.body())
|
||||
}
|
||||
if strings.Contains(last.body(), "more lines") {
|
||||
t.Errorf("summary invented a line count from a truncated sample: %.80q…", last.body())
|
||||
}
|
||||
}
|
||||
|
||||
// A provider error is not an acknowledged interruption the way /stop is, so
|
||||
|
||||
+138
-23
@@ -3,6 +3,7 @@ package gateway
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/webhookguard"
|
||||
@@ -65,37 +66,159 @@ func toolProgressBlock(name, status, preview string) string {
|
||||
return "🔧 " + name + " — " + status + "\n```text\n" + truncateRunes(preview, 180) + "\n```"
|
||||
}
|
||||
|
||||
// toolPreview reduces a tool result to one informative line.
|
||||
//
|
||||
// The result is described, never quoted: a search returns match lines that say
|
||||
// nothing on their own (a path, a line number, a closing brace), so the preview
|
||||
// states what came back and how much of it. The count comes from the tool's own
|
||||
// truncation notice when it printed one, because a count recomputed from the
|
||||
// visible sample describes the sample, not the result set -- rendering both
|
||||
// produced two different numbers for one search ("194 more lines" next to
|
||||
// "… 3 more lines"), which reads as noise.
|
||||
func toolPreview(name, output string) string {
|
||||
content, _ := unwrapToolContent(output)
|
||||
preview, skipped := compactToolPreview(content)
|
||||
if preview == "" {
|
||||
if strings.TrimSpace(content) == "" {
|
||||
return "completed"
|
||||
}
|
||||
return "completed with no printable preview"
|
||||
if strings.TrimSpace(content) == "" {
|
||||
return "completed"
|
||||
}
|
||||
remaining := max(countNonEmptyOrContentLines(content)-1-skipped, 0)
|
||||
if remaining > 0 {
|
||||
return fmt.Sprintf("%s\n… %d more lines", preview, remaining)
|
||||
// A tool that reported a real total is the only trustworthy source for
|
||||
// how much came back; anything we compute is about the sample we can see.
|
||||
if total, ok := toolReportedTotal(content); ok {
|
||||
return total
|
||||
}
|
||||
if summary, ok := searchResultSummary(content); ok {
|
||||
return summary
|
||||
}
|
||||
preview := firstInformativeLine(content)
|
||||
if preview == "" {
|
||||
return "completed with no printable preview"
|
||||
}
|
||||
_ = name
|
||||
return preview
|
||||
}
|
||||
|
||||
func compactToolPreview(output string) (string, int) {
|
||||
skipped := 0
|
||||
for line := range strings.SplitSeq(output, "\n") {
|
||||
// toolReportedTotal extracts the line total from the truncation notices the
|
||||
// tool layer prints (internal/tools/builtin: "[truncated: showing 2/194 lines,
|
||||
// …]"). Those notices are metadata, not content, so they are never rendered as
|
||||
// a preview line -- quoting one is what produced "[truncated: showing 3/197
|
||||
// lines, 412B/24.1KB]" as if it were a search hit.
|
||||
//
|
||||
// A notice that shows everything (showing N/N) is not a truncation and gets no
|
||||
// summary: the content speaks for itself.
|
||||
func toolReportedTotal(content string) (string, bool) {
|
||||
for line := range strings.SplitSeq(content, "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
shown, total, ok := parseTruncationNotice(line)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if total <= shown {
|
||||
continue
|
||||
}
|
||||
return fmt.Sprintf("%d lines total; showing %d", total, shown), true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// parseTruncationNotice reads "showing <shown>/<total> lines" out of a
|
||||
// truncation notice, tolerating the surrounding "[truncated: … ]" wrapper.
|
||||
func parseTruncationNotice(line string) (shown, total int, ok bool) {
|
||||
_, rest, found := strings.Cut(line, "showing ")
|
||||
if !found {
|
||||
return 0, 0, false
|
||||
}
|
||||
counts, _, found := strings.Cut(rest, " lines")
|
||||
if !found {
|
||||
return 0, 0, false
|
||||
}
|
||||
left, right, found := strings.Cut(counts, "/")
|
||||
if !found {
|
||||
return 0, 0, false
|
||||
}
|
||||
shown, errShown := strconv.Atoi(strings.TrimSpace(left))
|
||||
total, errTotal := strconv.Atoi(strings.TrimSpace(right))
|
||||
if errShown != nil || errTotal != nil {
|
||||
return 0, 0, false
|
||||
}
|
||||
return shown, total, true
|
||||
}
|
||||
|
||||
// searchResultSummary counts match lines in ripgrep-shaped output ("path-12-
|
||||
// text", "path:12:text", or a context separator). A search is the one tool
|
||||
// whose raw output is least useful quoted and most useful counted, so it is
|
||||
// summarised rather than sampled.
|
||||
func searchResultSummary(content string) (string, bool) {
|
||||
matches, _ := countSearchMatches(content)
|
||||
if matches == 0 {
|
||||
return "", false
|
||||
}
|
||||
return fmt.Sprintf("%d %s", matches, pluralize(matches, "match", "matches")), true
|
||||
}
|
||||
|
||||
// countSearchMatches counts match lines and whether any were truncated.
|
||||
func countSearchMatches(content string) (matches int, truncated bool) {
|
||||
for line := range strings.SplitSeq(content, "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
if line == "" || strings.HasPrefix(line, "[") {
|
||||
continue
|
||||
}
|
||||
if searchMatchLine(line) {
|
||||
matches++
|
||||
}
|
||||
}
|
||||
return matches, false
|
||||
}
|
||||
|
||||
// searchMatchLine reports whether line has ripgrep's "path-N-text" or
|
||||
// "path:N:text" shape. The path may contain colons, so the separator is found
|
||||
// by scanning for the last one that is followed by a line number.
|
||||
func searchMatchLine(line string) bool {
|
||||
if strings.HasPrefix(line, "--") && strings.Trim(line, "-") == "" {
|
||||
return true // context separator
|
||||
}
|
||||
for i := len(line) - 1; i > 0; i-- {
|
||||
if line[i] != ':' && line[i] != '-' {
|
||||
continue
|
||||
}
|
||||
digits := line[i+1:]
|
||||
end := 0
|
||||
for end < len(digits) && digits[end] >= '0' && digits[end] <= '9' {
|
||||
end++
|
||||
}
|
||||
if end == 0 || end >= len(digits) {
|
||||
continue
|
||||
}
|
||||
if digits[end] == ':' || digits[end] == '-' {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// firstInformativeLine returns the first line worth showing: not blank, not a
|
||||
// module-cache path, and not a truncation notice (which is metadata the total
|
||||
// path already consumed).
|
||||
func firstInformativeLine(content string) string {
|
||||
for line := range strings.SplitSeq(content, "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(line, "/pkg/mod/") {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
return truncateRunes(line, 120), skipped
|
||||
if _, _, ok := parseTruncationNotice(line); ok {
|
||||
continue
|
||||
}
|
||||
return truncateRunes(line, 120)
|
||||
}
|
||||
return "", skipped
|
||||
return ""
|
||||
}
|
||||
|
||||
func pluralize(n int, one, many string) string {
|
||||
if n == 1 {
|
||||
return one
|
||||
}
|
||||
return many
|
||||
}
|
||||
|
||||
func unwrapToolContent(output string) (string, bool) {
|
||||
@@ -116,14 +239,6 @@ func unwrapToolContent(output string) (string, bool) {
|
||||
return output, false
|
||||
}
|
||||
|
||||
func countNonEmptyOrContentLines(s string) int {
|
||||
if strings.TrimSpace(s) == "" {
|
||||
return 0
|
||||
}
|
||||
trimmed := strings.TrimRight(s, "\r\n")
|
||||
return strings.Count(trimmed, "\n") + 1
|
||||
}
|
||||
|
||||
func cleanToolError(name, raw string) string {
|
||||
line := firstNonEmptyLine(raw)
|
||||
prefix := "tool " + strings.TrimSpace(name) + ": "
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Operator report (2026-09-17): tool output in Telegram is unreadable. A
|
||||
// grep-heavy turn rendered as a wall of blocks like:
|
||||
//
|
||||
// 🔧 grep — done
|
||||
// ```text
|
||||
// /home/sam/.claude/config.json-322- }
|
||||
// … 194 more lines
|
||||
// ```
|
||||
//
|
||||
// Three faults, all in the render path:
|
||||
//
|
||||
// 1. the preview is an arbitrary match line -- a path, a line number and a
|
||||
// stray brace -- with no statement of what matched or how much;
|
||||
// 2. the "… N more lines" we append disagrees with the count the tool
|
||||
// already printed, so one result set shows two different numbers;
|
||||
// 3. a grep result ends with the tool's own truncation notice, which the
|
||||
// preview renders as if it were a match.
|
||||
|
||||
// TestGrepContextPreviewIsNotAnArbitraryMatchLine: the first line of ripgrep
|
||||
// context output is a path, a line number and (here) a closing brace. Showing
|
||||
// it tells the operator nothing about the search.
|
||||
func TestGrepContextPreviewIsNotAnArbitraryMatchLine(t *testing.T) {
|
||||
output := strings.Join([]string{
|
||||
"/home/sam/.claude/config.json-322- }",
|
||||
"/home/sam/.claude/config.json-323- }",
|
||||
"/home/sam/.claude/config.json-324- }",
|
||||
"",
|
||||
"[truncated: showing 3/197 lines, 412B/24.1KB]",
|
||||
}, "\n")
|
||||
|
||||
got := RenderToolCall(ToolCallEvent{Name: "grep", Output: output})
|
||||
|
||||
if strings.Contains(got, "config.json-322-") {
|
||||
t.Errorf("preview is an arbitrary match line, not a summary:\n%s", got)
|
||||
}
|
||||
if strings.Contains(got, "[truncated:") {
|
||||
t.Errorf("preview quoted the tool's truncation notice as content:\n%s", got)
|
||||
}
|
||||
// A summary is expected: the operator needs to know how much matched.
|
||||
if !strings.Contains(got, "197") {
|
||||
t.Errorf("preview does not state the result size; want the tool's own 197 lines:\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestToolPreviewDoesNotStateItsOwnLineCount: the renderer recomputes a line
|
||||
// count from the previewed text instead of using the total the tool already
|
||||
// reported, so the operator sees two different numbers for one result set --
|
||||
// the tool's "194 more lines" and our "… 3 more lines". Any count we invent
|
||||
// from a truncated preview is wrong by construction, so the renderer must not
|
||||
// state one at all.
|
||||
func TestToolPreviewDoesNotStateItsOwnLineCount(t *testing.T) {
|
||||
output := strings.Join([]string{
|
||||
"/a/b.go-12- return nil",
|
||||
"/a/c.go-40- return nil",
|
||||
"",
|
||||
"[truncated: showing 2/194 lines, 300B/12.0KB]",
|
||||
}, "\n")
|
||||
|
||||
got := RenderToolCall(ToolCallEvent{Name: "grep", Output: output})
|
||||
|
||||
if strings.Contains(got, "more lines") {
|
||||
t.Errorf("renderer invented a line count from a truncated preview; the tool's own count is the only true one:\n%s", got)
|
||||
}
|
||||
// The tool's real total should be what survives.
|
||||
if !strings.Contains(got, "194") {
|
||||
t.Errorf("render lost the tool's real total (194 lines):\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestToolRenderIsBoundedAndAggregatable: one rendered call must stay small so
|
||||
// a tool-heavy turn cannot crowd the answer out of a single Telegram frame.
|
||||
// Bounded at 220 runes so 14 calls stay well inside the 3900-rune frame.
|
||||
func TestToolRenderIsBoundedAndAggregatable(t *testing.T) {
|
||||
output := strings.Repeat("/very/long/path/to/some/file.go-1234- someLineOfSource();\n", 50)
|
||||
got := RenderToolCall(ToolCallEvent{Name: "grep", Output: output})
|
||||
if n := len([]rune(got)); n > 220 {
|
||||
t.Errorf("one rendered tool call is %d runes, want <= 220:\n%s", n, got)
|
||||
}
|
||||
// 14 such calls must leave the majority of the frame for the answer.
|
||||
if n := len([]rune(got)) * 14; n > 3900/2 {
|
||||
t.Errorf("14 rendered calls would consume %d of a 3900-rune frame", n)
|
||||
}
|
||||
}
|
||||
|
||||
// TestToolRenderKeepsShortOutputInformative: bounding must not throw away a
|
||||
// short result that genuinely fits -- the existing behaviour these tests must
|
||||
// not regress.
|
||||
func TestToolRenderKeepsShortOutputInformative(t *testing.T) {
|
||||
got := RenderToolCall(ToolCallEvent{Name: "shell", Output: "total 8\ndrwxr-xr-x 2 sam sam"})
|
||||
if !strings.Contains(got, "total 8") {
|
||||
t.Errorf("short output lost its content: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestToolRenderCountsMatchesForSearchTools: a search summary should say how
|
||||
// many matches, which is the one fact that makes it useful.
|
||||
func TestToolRenderCountsMatchesForSearchTools(t *testing.T) {
|
||||
var b strings.Builder
|
||||
for i := range 7 {
|
||||
fmt.Fprintf(&b, "/src/file%d.go-%d- match\n", i, i*10)
|
||||
}
|
||||
got := RenderToolCall(ToolCallEvent{Name: "grep", Output: b.String()})
|
||||
if !strings.Contains(got, "7") {
|
||||
t.Errorf("search preview does not report the match count:\n%s", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user