Skip to content

Add unit tests for example_util.convert_examples_to_text #4623

@xxlest

Description

@xxlest

Summary

src/google/adk/examples/example_util.py:49 has a TODO from the original author:

# TODO(yaojie): Add unit tests for this function.
def convert_examples_to_text(examples: list[Example], model: Optional[str]) -> str:

This function handles few-shot example formatting for system instructions and currently has zero test coverage. The related build_example_si and _get_latest_message_from_user helpers are also untested.

Proposed test cases

  • Basic text-only examples
  • Function call + function response formatting
  • Mixed content (text + function call)
  • Empty examples list
  • Gemini 2 vs non-Gemini 2 format branch (_FUNCTION_PREFIX vs _FUNCTION_CALL_PREFIX)
  • build_example_si with list input vs BaseExampleProvider input
  • _get_latest_message_from_user with empty session, non-user author, function responses

Happy to submit a PR for this.

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementationneeds review[Status] The PR/issue is awaiting review from the maintainer

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions