Skip to content

refactor: add a shared function for tool call & return ids collection. - #775

Open
StarsExpress wants to merge 1 commit into
mpfaffenberger:mainfrom
StarsExpress:refactor-message-parts-ids
Open

refactor: add a shared function for tool call & return ids collection.#775
StarsExpress wants to merge 1 commit into
mpfaffenberger:mainfrom
StarsExpress:refactor-message-parts-ids

Conversation

@StarsExpress

@StarsExpress StarsExpress commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Refs issue #463 to align repeated tool call & return ids collection.


Repeated code block

code_puppy/agents/_history.pyprune_interrupted_tool_calls and has_pending_tool_calls:

tool_call_ids: Set[str] = set()
tool_return_ids: Set[str] = set()

for msg in messages:
    for part in getattr(msg, "parts", []) or []:
        kind = _classify_tool_part(part)

        if kind == "call":
            tool_call_ids.add(part.tool_call_id)

        elif kind == "return":
            tool_return_ids.add(part.tool_call_id)

Extraction

By putting aforementioned repeated code into _collect_tool_ids inside agents/_history.py, prune_interrupted_tool_calls and has_pending_tool_calls both use it to get tool_call_ids and tool_return_ids.

@StarsExpress StarsExpress changed the title refactor: added a shared function for tool call & return ids collection. refactor: add a shared function for tool call & return ids collection. Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant