feat!: Full code can now be generated by an external model and shared with the AI tool (Claude Code / Codex etc)!
model definitions now support a new `allow_code_generation` flag, only to be used with higher reasoning models such as GPT-5-Pro and-Gemini 2.5-Pro When `true`, the `chat` tool can now request the external model to generate a full implementation / update / instructions etc and then share the implementation with the calling agent. This effectively allows us to utilize more powerful models such as GPT-5-Pro to generate code for us or entire implementations (which are either API-only or part of the $200 Pro plan from within the ChatGPT app)
This commit is contained in:
@@ -38,12 +38,14 @@ class TestChatTool:
|
||||
|
||||
# Required fields
|
||||
assert "prompt" in schema["required"]
|
||||
assert "working_directory" in schema["required"]
|
||||
|
||||
# Properties
|
||||
properties = schema["properties"]
|
||||
assert "prompt" in properties
|
||||
assert "files" in properties
|
||||
assert "images" in properties
|
||||
assert "working_directory" in properties
|
||||
|
||||
def test_request_model_validation(self):
|
||||
"""Test that the request model validates correctly"""
|
||||
@@ -54,6 +56,7 @@ class TestChatTool:
|
||||
"images": ["test.png"],
|
||||
"model": "anthropic/claude-opus-4.1",
|
||||
"temperature": 0.7,
|
||||
"working_directory": "/tmp", # Dummy absolute path
|
||||
}
|
||||
|
||||
request = ChatRequest(**request_data)
|
||||
@@ -62,6 +65,7 @@ class TestChatTool:
|
||||
assert request.images == ["test.png"]
|
||||
assert request.model == "anthropic/claude-opus-4.1"
|
||||
assert request.temperature == 0.7
|
||||
assert request.working_directory == "/tmp"
|
||||
|
||||
def test_required_fields(self):
|
||||
"""Test that required fields are enforced"""
|
||||
@@ -69,7 +73,7 @@ class TestChatTool:
|
||||
from pydantic import ValidationError
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
ChatRequest(model="anthropic/claude-opus-4.1")
|
||||
ChatRequest(model="anthropic/claude-opus-4.1", working_directory="/tmp")
|
||||
|
||||
def test_model_availability(self):
|
||||
"""Test that model availability works"""
|
||||
@@ -96,7 +100,7 @@ class TestChatTool:
|
||||
@pytest.mark.asyncio
|
||||
async def test_prompt_preparation(self):
|
||||
"""Test that prompt preparation works correctly"""
|
||||
request = ChatRequest(prompt="Test prompt", files=[])
|
||||
request = ChatRequest(prompt="Test prompt", files=[], working_directory="/tmp")
|
||||
|
||||
# Mock the system prompt and file handling
|
||||
with patch.object(self.tool, "get_system_prompt", return_value="System prompt"):
|
||||
@@ -113,7 +117,7 @@ class TestChatTool:
|
||||
def test_response_formatting(self):
|
||||
"""Test that response formatting works correctly"""
|
||||
response = "Test response content"
|
||||
request = ChatRequest(prompt="Test")
|
||||
request = ChatRequest(prompt="Test", working_directory="/tmp")
|
||||
|
||||
formatted = self.tool.format_response(response, request)
|
||||
|
||||
@@ -146,6 +150,7 @@ class TestChatTool:
|
||||
|
||||
required_fields = self.tool.get_required_fields()
|
||||
assert "prompt" in required_fields
|
||||
assert "working_directory" in required_fields
|
||||
|
||||
|
||||
class TestChatRequestModel:
|
||||
@@ -160,10 +165,11 @@ class TestChatRequestModel:
|
||||
assert "context" in CHAT_FIELD_DESCRIPTIONS["prompt"]
|
||||
assert "full-paths" in CHAT_FIELD_DESCRIPTIONS["files"] or "absolute" in CHAT_FIELD_DESCRIPTIONS["files"]
|
||||
assert "visual context" in CHAT_FIELD_DESCRIPTIONS["images"]
|
||||
assert "directory" in CHAT_FIELD_DESCRIPTIONS["working_directory"].lower()
|
||||
|
||||
def test_default_values(self):
|
||||
"""Test that default values work correctly"""
|
||||
request = ChatRequest(prompt="Test")
|
||||
request = ChatRequest(prompt="Test", working_directory="/tmp")
|
||||
|
||||
assert request.prompt == "Test"
|
||||
assert request.files == [] # Should default to empty list
|
||||
@@ -173,7 +179,7 @@ class TestChatRequestModel:
|
||||
"""Test that ChatRequest properly inherits from ToolRequest"""
|
||||
from tools.shared.base_models import ToolRequest
|
||||
|
||||
request = ChatRequest(prompt="Test")
|
||||
request = ChatRequest(prompt="Test", working_directory="/tmp")
|
||||
assert isinstance(request, ToolRequest)
|
||||
|
||||
# Should have inherited fields
|
||||
|
||||
Reference in New Issue
Block a user