Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
aisbf
Commits
fa75c0a6
Commit
fa75c0a6
authored
Feb 08, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tool call tracking - use set to track seen IDs instead of list slicing
parent
e8f7a267
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
handlers.py
aisbf/handlers.py
+7
-4
No files found.
aisbf/handlers.py
View file @
fa75c0a6
...
@@ -411,7 +411,7 @@ class RequestHandler:
...
@@ -411,7 +411,7 @@ class RequestHandler:
# Note: Google returns accumulated text, so we need to track and send only deltas
# Note: Google returns accumulated text, so we need to track and send only deltas
chunk_id
=
0
chunk_id
=
0
accumulated_text
=
""
# Track text we've already sent
accumulated_text
=
""
# Track text we've already sent
accumulated_tool_calls
=
[]
# Track tool call
s we've already sent
seen_tool_call_ids
=
set
()
# Track which tool call ID
s we've already sent
last_chunk_id
=
None
# Track the last chunk for finish_reason
last_chunk_id
=
None
# Track the last chunk for finish_reason
created_time
=
int
(
time
.
time
())
created_time
=
int
(
time
.
time
())
response_id
=
f
"google-{request_data['model']}-{created_time}"
response_id
=
f
"google-{request_data['model']}-{created_time}"
...
@@ -475,9 +475,12 @@ class RequestHandler:
...
@@ -475,9 +475,12 @@ class RequestHandler:
delta_text
=
chunk_text
[
len
(
accumulated_text
):]
if
chunk_text
.
startswith
(
accumulated_text
)
else
chunk_text
delta_text
=
chunk_text
[
len
(
accumulated_text
):]
if
chunk_text
.
startswith
(
accumulated_text
)
else
chunk_text
accumulated_text
=
chunk_text
# Update accumulated text for next iteration
accumulated_text
=
chunk_text
# Update accumulated text for next iteration
# Calculate delta tool calls (only new tool calls since last chunk)
# Calculate delta tool calls (only tool calls we haven't seen before)
delta_tool_calls
=
chunk_tool_calls
[
len
(
accumulated_tool_calls
):]
if
chunk_tool_calls
else
[]
delta_tool_calls
=
[]
accumulated_tool_calls
=
chunk_tool_calls
# Update accumulated tool calls for next iteration
for
tool_call
in
chunk_tool_calls
:
if
tool_call
[
"id"
]
not
in
seen_tool_call_ids
:
delta_tool_calls
.
append
(
tool_call
)
seen_tool_call_ids
.
add
(
tool_call
[
"id"
])
# Check if this is the last chunk
# Check if this is the last chunk
is_last_chunk
=
(
chunk_idx
==
total_chunks
-
1
)
is_last_chunk
=
(
chunk_idx
==
total_chunks
-
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment