Skip to content

Commit 848b465

Browse files
mefogleclaude
andcommitted
Fix ADKAgent test suite for new architecture
Updated all test fixtures and endpoint implementation to match the new ADKAgent.run(input_data) signature after removing agent_id parameter. All 271 tests now pass with the simplified architecture from issue-24-cleanup-agent-registration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 849ca93 commit 848b465

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

typescript-sdk/integrations/adk-middleware/CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [0.5.0] - 2025-01-08
10+
## [0.5.0] - 2025-08-05
1111

1212
### Breaking Changes
1313
- **BREAKING**: ADKAgent constructor now requires `adk_agent` parameter instead of `agent_id` for direct agent embedding
@@ -25,8 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525

2626
### Fixed
2727
- **FIXED**: All 271 tests now pass with new simplified architecture
28-
- **EXAMPLES**: Updated examples to demonstrate direct agent embedding pattern
28+
- **TESTS**: Updated all test fixtures to match new ADKAgent.run(input_data) signature without agent_id parameter
29+
- **TESTS**: Fixed test expectations in test_endpoint.py to work with direct agent embedding architecture
2930
- **TESTS**: Updated all test fixtures to work with new agent embedding pattern
31+
- **EXAMPLES**: Updated examples to demonstrate direct agent embedding pattern
3032

3133
### Added
3234
- **NEW**: SystemMessage support for ADK agents (issue #22) - SystemMessages as first message are now appended to agent instructions

typescript-sdk/integrations/adk-middleware/src/adk_middleware/endpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def adk_endpoint(input_data: RunAgentInput, request: Request):
3636
async def event_generator():
3737
"""Generate events from ADK agent."""
3838
try:
39-
async for event in agent.run(input_data, agent_id):
39+
async for event in agent.run(input_data):
4040
try:
4141
encoded = encoder.encode(event)
4242
logger.debug(f"HTTP Response: {encoded}")

typescript-sdk/integrations/adk-middleware/tests/test_endpoint.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def test_endpoint_agent_id_extraction(self, mock_encoder_class, app, mock_agent,
117117
client = TestClient(app)
118118
response = client.post("/agent123", json=sample_input.model_dump())
119119

120-
# Agent should be called with agent_id extracted from path
121-
mock_agent.run.assert_called_once_with(sample_input, "agent123")
120+
# Agent should be called with just the input data
121+
mock_agent.run.assert_called_once_with(sample_input)
122122
assert response.status_code == 200
123123

124124
@patch('adk_middleware.endpoint.EventEncoder')
@@ -142,8 +142,8 @@ def test_endpoint_root_path_agent_id(self, mock_encoder_class, app, mock_agent,
142142
client = TestClient(app)
143143
response = client.post("/", json=sample_input.model_dump())
144144

145-
# Agent should be called with empty agent_id for root path
146-
mock_agent.run.assert_called_once_with(sample_input, "")
145+
# Agent should be called with just the input data
146+
mock_agent.run.assert_called_once_with(sample_input)
147147
assert response.status_code == 200
148148

149149
@patch('adk_middleware.endpoint.EventEncoder')
@@ -167,7 +167,7 @@ def test_endpoint_successful_event_streaming(self, mock_logger, mock_encoder_cla
167167
run_id="test_run"
168168
)
169169

170-
async def mock_agent_run(input_data, agent_id):
170+
async def mock_agent_run(input_data):
171171
yield mock_event1
172172
yield mock_event2
173173

@@ -204,7 +204,7 @@ def test_endpoint_encoding_error_handling(self, mock_logger, mock_encoder_class,
204204
run_id="test_run"
205205
)
206206

207-
async def mock_agent_run(input_data, agent_id):
207+
async def mock_agent_run(input_data):
208208
yield mock_event
209209

210210
mock_agent.run = mock_agent_run
@@ -245,7 +245,7 @@ def test_endpoint_encoding_error_double_failure(self, mock_logger, mock_encoder_
245245
run_id="test_run"
246246
)
247247

248-
async def mock_agent_run(input_data, agent_id):
248+
async def mock_agent_run(input_data):
249249
yield mock_event
250250

251251
mock_agent.run = mock_agent_run
@@ -276,7 +276,7 @@ def test_endpoint_agent_error_handling(self, mock_logger, mock_encoder_class, ap
276276
mock_encoder_class.return_value = mock_encoder
277277

278278
# Mock agent to raise an error
279-
async def mock_agent_run(input_data, agent_id):
279+
async def mock_agent_run(input_data):
280280
raise RuntimeError("Agent failed")
281281

282282
mock_agent.run = mock_agent_run
@@ -309,7 +309,7 @@ def test_endpoint_agent_error_encoding_failure(self, mock_logger, mock_encoder_c
309309
mock_encoder_class.return_value = mock_encoder
310310

311311
# Mock agent to raise an error
312-
async def mock_agent_run(input_data, agent_id):
312+
async def mock_agent_run(input_data):
313313
raise RuntimeError("Agent failed")
314314

315315
mock_agent.run = mock_agent_run
@@ -345,7 +345,7 @@ def test_endpoint_returns_streaming_response(self, mock_encoder_class, app, mock
345345
run_id="test_run"
346346
)
347347

348-
async def mock_agent_run(input_data, agent_id):
348+
async def mock_agent_run(input_data):
349349
yield mock_event
350350

351351
mock_agent.run = mock_agent_run
@@ -385,7 +385,7 @@ def test_endpoint_no_accept_header(self, mock_encoder_class, app, mock_agent, sa
385385
run_id="test_run"
386386
)
387387

388-
async def mock_agent_run(input_data, agent_id):
388+
async def mock_agent_run(input_data):
389389
yield mock_event
390390

391391
mock_agent.run = mock_agent_run
@@ -459,7 +459,7 @@ def test_create_app_functional_test(self, mock_encoder_class, mock_agent):
459459
run_id="test_run"
460460
)
461461

462-
async def mock_agent_run(input_data, agent_id):
462+
async def mock_agent_run(input_data):
463463
yield mock_event
464464

465465
mock_agent.run = mock_agent_run
@@ -530,8 +530,8 @@ def test_full_endpoint_flow(self, mock_encoder_class, mock_agent, sample_input):
530530

531531
call_args = []
532532

533-
async def mock_agent_run(input_data, agent_id):
534-
call_args.append((input_data, agent_id))
533+
async def mock_agent_run(input_data):
534+
call_args.append(input_data)
535535
for event in events:
536536
yield event
537537

@@ -552,8 +552,7 @@ async def mock_agent_run(input_data, agent_id):
552552

553553
# Verify agent was called correctly
554554
assert len(call_args) == 1
555-
assert call_args[0][0] == sample_input
556-
assert call_args[0][1] == "integration"
555+
assert call_args[0] == sample_input
557556

558557
# Verify events were encoded
559558
assert mock_encoder.encode.call_count == len(events)
@@ -589,7 +588,7 @@ def test_endpoint_with_long_running_stream(self, mock_encoder_class, mock_agent,
589588
mock_encoder_class.return_value = mock_encoder
590589

591590
# Mock agent to return many events
592-
async def mock_agent_run(input_data, agent_id):
591+
async def mock_agent_run(input_data):
593592
for i in range(10):
594593
yield RunStartedEvent(
595594
type=EventType.RUN_STARTED,

0 commit comments

Comments
 (0)