Skip to content

Fix Pylance diagnostics in sgr_so_tool_calling_agent.py #95

Description

@rbctmz

Description:

  • Summary: sgr_deep_research/core/agents/sgr_so_tool_calling_agent.py currently feeds raw dicts/unchecked completions into the OpenAI streaming APIs, so Pylance fires reportArgumentType, reportAssignmentType, and reportOptionalSubscript errors (lines 48, 53‑66, 85).

  • Problems:

    1. tool_choice is a plain dict, but the API expects ChatCompletionToolChoiceOptionParam.
    2. The code indexes choices[0].message.tool_calls[0].function.parsed_arguments without null guards, so ReasoningTool may be assigned from object | None, and subscripting None is invalid.
    3. The second pass assumes stream.get_final_completion() always returns a ReasoningTool, but it can be None, so the assignment is unsafe.
    4. reasoning.tool_name is str | None, but add_tool_call expects a str, so we end up calling it with None.
  • Suggestion: add explicit null/empty guards, use the typed tool_choice, validate that parsed arguments are a ReasoningTool, and ensure tool_name is non-null before logging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions