audit: tool_call_id replay, CoT dup guard, notepad/shell/sqlite/detok hardening (BUG-04/05/06/07/11/16, SEC-11)
This commit is contained in:
1 parent
b8e1a07e77
commit
09542e05a1
7 files changed
+276
-32
No files matched your search
+12
-2
@@ -163,6 +163,8 @@ pub struct InklingDialect {
|
||||
think_acc: String,
|
||||
end_ws: String,
|
||||
emitted_visible: bool,
|
||||
/// Thinking already streamed live by `emit` (so `finish` must not re-emit it).
|
||||
emitted_reasoning: bool,
|
||||
/// How many tool frames have been rendered (diagnostics).
|
||||
pub calls: u32,
|
||||
}
|
||||
@@ -228,6 +230,7 @@ impl InklingDialect {
|
||||
State::Think => {
|
||||
self.append_think(chunk);
|
||||
out.push(Out::reasoning(chunk));
|
||||
self.emitted_reasoning = true;
|
||||
}
|
||||
State::ThinkEnd => {
|
||||
if chunk.trim().is_empty() {
|
||||
@@ -237,6 +240,7 @@ impl InklingDialect {
|
||||
let combined = format!("{}{}{}", tag::END_MESSAGE, self.end_ws, chunk);
|
||||
self.append_think(&combined);
|
||||
out.push(Out::reasoning(combined));
|
||||
self.emitted_reasoning = true;
|
||||
self.end_ws.clear();
|
||||
self.state = State::Think;
|
||||
}
|
||||
@@ -318,6 +322,10 @@ impl InklingDialect {
|
||||
State::ThinkEnd => {
|
||||
let held = format!("{}{}", tag::END_MESSAGE, self.end_ws);
|
||||
self.append_think(&held);
|
||||
// Stream the quoted end-message live (mirrors TextEnd below):
|
||||
// it is thinking text, not a channel end, and must not be lost.
|
||||
out.push(Out::reasoning(held));
|
||||
self.emitted_reasoning = true;
|
||||
self.end_ws.clear();
|
||||
}
|
||||
State::Text => {
|
||||
@@ -424,11 +432,13 @@ impl InklingDialect {
|
||||
self.emitted_visible = true;
|
||||
}
|
||||
}
|
||||
// #6682: budget expired inside thinking with no visible answer yet:
|
||||
// surface the truncated thinking rather than an empty 200 OK.
|
||||
// #6682: budget expired inside thinking with no visible answer yet.
|
||||
// Thinking is streamed live by `emit`, so only surface the buffer if
|
||||
// it was somehow NOT streamed — never duplicate the live CoT (BUG-06).
|
||||
State::Think | State::ThinkEnd
|
||||
if reason == Some("length")
|
||||
&& !self.emitted_visible
|
||||
&& !self.emitted_reasoning
|
||||
&& !think.trim().is_empty() =>
|
||||
{
|
||||
out.push(Out::reasoning(think));
|
||||
|
||||
Reference in new issue
Block a user