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:
Fahad
2025-10-07 18:49:13 +04:00
parent 04f7ce5b03
commit ece8a5ebed
29 changed files with 1008 additions and 122 deletions

View File

@@ -200,7 +200,7 @@ class TestAutoModeComprehensive:
assert tool.get_model_category() == expected_category
@pytest.mark.asyncio
async def test_auto_mode_with_gemini_only_uses_correct_models(self):
async def test_auto_mode_with_gemini_only_uses_correct_models(self, tmp_path):
"""Test that auto mode with only Gemini uses flash for fast tools and pro for reasoning tools."""
provider_config = {
@@ -234,9 +234,13 @@ class TestAutoModeComprehensive:
)
with patch.object(ModelProviderRegistry, "get_provider_for_model", return_value=mock_provider):
workdir = tmp_path / "chat_artifacts"
workdir.mkdir(parents=True, exist_ok=True)
# Test ChatTool (FAST_RESPONSE) - should prefer flash
chat_tool = ChatTool()
await chat_tool.execute({"prompt": "test", "model": "auto"}) # This should trigger auto selection
await chat_tool.execute(
{"prompt": "test", "model": "auto", "working_directory": str(workdir)}
) # This should trigger auto selection
# In auto mode, the tool should get an error requiring model selection
# but the suggested model should be flash
@@ -355,7 +359,7 @@ class TestAutoModeComprehensive:
# would show models from all providers when called
@pytest.mark.asyncio
async def test_auto_mode_model_parameter_required_error(self):
async def test_auto_mode_model_parameter_required_error(self, tmp_path):
"""Test that auto mode properly requires model parameter and suggests correct model."""
provider_config = {
@@ -384,9 +388,12 @@ class TestAutoModeComprehensive:
# Test with ChatTool (FAST_RESPONSE category)
chat_tool = ChatTool()
workdir = tmp_path / "chat_artifacts"
workdir.mkdir(parents=True, exist_ok=True)
result = await chat_tool.execute(
{
"prompt": "test"
"prompt": "test",
"working_directory": str(workdir),
# Note: no model parameter provided in auto mode
}
)
@@ -508,7 +515,7 @@ class TestAutoModeComprehensive:
assert fast_response is not None
@pytest.mark.asyncio
async def test_actual_model_name_resolution_in_auto_mode(self):
async def test_actual_model_name_resolution_in_auto_mode(self, tmp_path):
"""Test that when a model is selected in auto mode, the tool executes successfully."""
provider_config = {
@@ -547,7 +554,11 @@ class TestAutoModeComprehensive:
with patch.object(ModelProviderRegistry, "get_provider_for_model", return_value=mock_provider):
chat_tool = ChatTool()
result = await chat_tool.execute({"prompt": "test", "model": "flash"}) # Use alias in auto mode
workdir = tmp_path / "chat_artifacts"
workdir.mkdir(parents=True, exist_ok=True)
result = await chat_tool.execute(
{"prompt": "test", "model": "flash", "working_directory": str(workdir)}
) # Use alias in auto mode
# Should succeed with proper model resolution
assert len(result) == 1