Graphi 53/improve func spec for tool calls#87
Merged
Conversation
Contributor
GuanyiLi-Craig
commented
Dec 7, 2025
- Update function spec
- add code string to topic condition
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request enhances the function specification system for LLM tool calls and improves topic condition serialization. The main changes include a comprehensive rewrite of the type-to-schema conversion logic to support more complex Python types, the addition of human-readable code strings alongside base64-encoded conditions in topic manifests, and updates to the ParameterSchema model to use Pydantic's flexible extra fields configuration.
- Significantly improved type-to-schema conversion supporting Union types, sequences, mappings, dataclasses, enums, and annotated types
- Added code string representation to topic conditions for better debugging and readability
- Updated
FunctionSpecto include optional output schema information
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Version bump to 0.0.32 and addition of new platform-specific greenlet and psycopg2-binary wheels |
| grafi/common/decorators/llm_function.py | Major refactor introducing comprehensive type-to-JSON schema conversion with support for complex types, dataclasses, enums, and proper handling of Optional/Union types |
| grafi/common/models/function_spec.py | Updated ParameterSchema to use flexible extra fields and added output_schema to FunctionSpec |
| grafi/topics/topic_base.py | Enhanced to_dict() to include human-readable source code alongside base64-encoded condition; updated from_dict() to handle both formats for backward compatibility |
| grafi/topics/topic_impl/*.py | Updated all topic implementations to handle both old (string) and new (dict with base64 + code) condition formats during deserialization |
| tests_integration/function_call_assistant/simple_function_call_assistant.py | Refactored to define agent_output_condition at module level and pass it during OutputTopic construction for better code organization |
| tests_integration/function_call_assistant/simple_function_call_assistant_complex_function_example.py | New integration test demonstrating complex function with list and Optional parameters |
| tests_integration/function_call_assistant/complex_function_call_assistant_deserialize_assistant_example.py | New test for assistant deserialization from manifest |
| tests_integration/function_call_assistant/complex_function_manifest.json | New manifest file showing serialized assistant with function specs and topic conditions in new format |
| tests/tools/llm_function_calls/test_function_call_tool.py | Added tests for complex function types, invocation, and deserialization with Pydantic models |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ayomaska18
approved these changes
Dec 21, 2025
ayomaska18
approved these changes
Dec 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.