Skip to content

fix: enforce LSP by returning string content from GeminiClient complete() #264

Description

@rajsingh1301

Description

This PR updates the GeminiClient in core/intelligence/llm_client.py to correctly extract and return the inner text from the Google Generative AI response, standardizing the return type to str across all LLM clients.

Why this is necessary

The BaseLLMClient abstract class defines a strict contract that the complete() method must return a str. Currently, OpenAIClient and LlamaClient honor this contract. However, GeminiClient was returning the raw types.GenerateContentResponse Python object.

This is a violation of the Liskov Substitution Principle (LSP) and can cause runtime crashes whenever the backend is switched to Gemini.

Any downstream consumer of the LLM client (such as TaskDecomposer) that attempts to run standard string methods like .strip(), .split(), or len() on the complete() output may fail with an AttributeError if LLM_BACKEND=gemini.

Proposed Fix

  • Updated the return type hint on GeminiClient.complete() from types.GenerateContentResponse to str
  • Modified the return statement to extract the text property via return response.text

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactor (code quality improvement)

Testing

  • Verified that downstream consumers can now reliably call .strip() and other string methods regardless of the configured LLM backend

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions