Skip to content

Commit 8e31040

Browse files
authored
Fix AI agent invocation handling for dict responses (#28)
* fix issue with AI agent invoke * simplify agent response * update poetry version * update changelog
1 parent 277a8b7 commit 8e31040

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.10] - 2025-06-04
9+
10+
### Changed
11+
- Simplified AI agent response handling by removing conditional API validation.
12+
813
## [0.1.8] - 2025-04-27
914

1015
### Changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mcp-server-port"
3-
version = "0.2.9"
3+
version = "0.2.10"
44
authors = [
55
{ name = "Matan Grady", email = "[email protected]" }
66
]
@@ -32,7 +32,7 @@ include = [
3232
]
3333
[tool.poetry]
3434
name = "mcp-server-port"
35-
version = "0.2.9"
35+
version = "0.2.10"
3636
description = "Port's MCP server"
3737
packages = [
3838
{ include = "src" }

src/client/agent.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ async def trigger_agent(self, prompt: str) -> PortAgentTriggerResponse:
2929
raise PortError("Response missing required invocation identifier")
3030

3131
try:
32-
if config.api_validation_enabled:
33-
return PortAgentTriggerResponse(**response_data)
34-
else:
35-
return PortAgentTriggerResponse.construct(**response_data)
32+
return PortAgentTriggerResponse(**response_data)
3633
except Exception as e:
3734
logger.error(f"Failed to parse trigger agent response: {e}")
3835
logger.error(f"Response data: {response_data}")

src/tools/ai_agent/invoke_ai_agent.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ def __init__(self, port_client: PortClient):
4242
self.port_client = port_client
4343

4444
async def invoke_ai_agent(self, props: InvokeAIAGentToolSchema) -> dict[str, Any]:
45-
# Handle both dict input and schema object
4645
prompt = props.prompt
47-
# Trigger agent
4846
logger.info(f"Invoking Port's AI agent with prompt: {prompt[:50]}{'...' if len(prompt) > 50 else ''}")
4947
response = await self.port_client.trigger_agent(prompt)
5048

51-
# Get identifier from the Pydantic response object
5249
identifier = response.invocation.identifier
5350

5451
logger.info(f"Got invocation identifier: {identifier}")

0 commit comments

Comments
 (0)