kagent-adk 0.6.9__tar.gz → 0.6.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kagent-adk might be problematic. Click here for more details.
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/PKG-INFO +1 -1
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/pyproject.toml +1 -1
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/models/_openai.py +33 -16
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/.gitignore +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/.python-version +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/README.md +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/__init__.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/_a2a.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/_agent_executor.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/_session_service.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/_token.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/cli.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/converters/__init__.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/converters/event_converter.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/converters/part_converter.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/converters/request_converter.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/models/__init__.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/src/kagent/adk/types.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/tests/__init__.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/tests/unittests/__init__.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/tests/unittests/models/__init__.py +0 -0
- {kagent_adk-0.6.9 → kagent_adk-0.6.10}/tests/unittests/models/test_openai.py +0 -0
|
@@ -55,8 +55,13 @@ def _convert_content_to_openai_messages(
|
|
|
55
55
|
system_message: ChatCompletionSystemMessageParam = {"role": "system", "content": system_instruction}
|
|
56
56
|
messages.append(system_message)
|
|
57
57
|
|
|
58
|
-
#
|
|
59
|
-
|
|
58
|
+
# First pass: collect all function responses to match with tool calls
|
|
59
|
+
all_function_responses = {}
|
|
60
|
+
for content in contents:
|
|
61
|
+
for part in content.parts or []:
|
|
62
|
+
if part.function_response:
|
|
63
|
+
tool_call_id = part.function_response.id or "call_1"
|
|
64
|
+
all_function_responses[tool_call_id] = part.function_response
|
|
60
65
|
|
|
61
66
|
for content in contents:
|
|
62
67
|
role = _convert_role_to_openai(content.role)
|
|
@@ -83,23 +88,14 @@ def _convert_content_to_openai_messages(
|
|
|
83
88
|
}
|
|
84
89
|
image_parts.append(image_part)
|
|
85
90
|
|
|
86
|
-
#
|
|
87
|
-
|
|
88
|
-
tool_call_id = func_response.function_response.id or "call_1"
|
|
89
|
-
if tool_call_id in pending_tool_calls:
|
|
90
|
-
tool_message: ChatCompletionToolMessageParam = {
|
|
91
|
-
"role": "tool",
|
|
92
|
-
"tool_call_id": tool_call_id,
|
|
93
|
-
"content": str(func_response.function_response.response.get("result", ""))
|
|
94
|
-
if func_response.function_response.response
|
|
95
|
-
else "",
|
|
96
|
-
}
|
|
97
|
-
messages.append(tool_message)
|
|
98
|
-
pending_tool_calls.discard(tool_call_id)
|
|
91
|
+
# Function responses are now handled together with function calls
|
|
92
|
+
# This ensures proper pairing and prevents orphaned tool messages
|
|
99
93
|
|
|
100
94
|
# Handle function calls (assistant messages with tool_calls)
|
|
101
95
|
if function_calls:
|
|
102
96
|
tool_calls = []
|
|
97
|
+
tool_response_messages = []
|
|
98
|
+
|
|
103
99
|
for func_call in function_calls:
|
|
104
100
|
tool_call_function: ToolCallFunction = {
|
|
105
101
|
"name": func_call.function_call.name or "",
|
|
@@ -112,7 +108,25 @@ def _convert_content_to_openai_messages(
|
|
|
112
108
|
"function": tool_call_function,
|
|
113
109
|
}
|
|
114
110
|
tool_calls.append(tool_call)
|
|
115
|
-
|
|
111
|
+
|
|
112
|
+
# Check if we have a response for this tool call
|
|
113
|
+
if tool_call_id in all_function_responses:
|
|
114
|
+
func_response = all_function_responses[tool_call_id]
|
|
115
|
+
tool_message: ChatCompletionToolMessageParam = {
|
|
116
|
+
"role": "tool",
|
|
117
|
+
"tool_call_id": tool_call_id,
|
|
118
|
+
"content": str(func_response.response.get("result", "")) if func_response.response else "",
|
|
119
|
+
}
|
|
120
|
+
tool_response_messages.append(tool_message)
|
|
121
|
+
else:
|
|
122
|
+
# If no response is available, create a placeholder response
|
|
123
|
+
# This prevents the OpenAI API error
|
|
124
|
+
tool_message: ChatCompletionToolMessageParam = {
|
|
125
|
+
"role": "tool",
|
|
126
|
+
"tool_call_id": tool_call_id,
|
|
127
|
+
"content": "No response available for this function call.",
|
|
128
|
+
}
|
|
129
|
+
tool_response_messages.append(tool_message)
|
|
116
130
|
|
|
117
131
|
# Create assistant message with tool calls
|
|
118
132
|
text_content = "\n".join(text_parts) if text_parts else None
|
|
@@ -123,6 +137,9 @@ def _convert_content_to_openai_messages(
|
|
|
123
137
|
}
|
|
124
138
|
messages.append(assistant_message)
|
|
125
139
|
|
|
140
|
+
# Add all tool response messages immediately after the assistant message
|
|
141
|
+
messages.extend(tool_response_messages)
|
|
142
|
+
|
|
126
143
|
# Handle regular text/image messages (only if no function calls)
|
|
127
144
|
elif text_parts or image_parts:
|
|
128
145
|
if role == "user":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|