Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
195 commits
Select commit Hold shift + click to select a range
173085d
feat: initial implementation of ADK middleware for AG-UI Protocol
mefogle Jul 4, 2025
b9c2977
feat: major refactoring and enhancements to ADK middleware
mefogle Jul 5, 2025
40ef583
chore: update all python3 references to python for consistency
mefogle Jul 5, 2025
04d4cda
feat: add default app_name behavior using agent name from registry
mefogle Jul 5, 2025
6b7108a
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Jul 5, 2025
865f7c7
refactor: move all tests to tests/ directory for better organization
mefogle Jul 5, 2025
86094a4
fix: update changelog for test reorganization
mefogle Jul 5, 2025
5f73078
Updating requirements.txt.
mefogle Jul 5, 2025
d81d82b
Added version for asyncio.
mefogle Jul 5, 2025
11aca27
docs: update README to reflect current implementation status
mefogle Jul 5, 2025
aa04096
feat: implement full pytest compatibility for test suite
mefogle Jul 5, 2025
2683a30
fix: remove accidentally committed ADK_Middleware directory and CLAUD…
mefogle Jul 5, 2025
a1ebaa3
docs: update README feature status to reflect current implementation
mefogle Jul 5, 2025
555a3e3
refactor: separate dev dependencies and fix README examples
mefogle Jul 6, 2025
589303c
feat: add automatic session memory and refactor session management
mefogle Jul 6, 2025
eebd544
refactor: simplify logging system to use standard Python logging
mefogle Jul 6, 2025
51b663f
fix adk_middleware python module and added adk-middleware demo in doj…
syedfakher27 Jul 6, 2025
afbaf00
import change
syedfakher27 Jul 7, 2025
246bee6
venv in git ignore
syedfakher27 Jul 7, 2025
e41471d
fixing test adk_middleware imports
syedfakher27 Jul 7, 2025
ad407cb
all test cases fixed
syedfakher27 Jul 7, 2025
41dd2c1
Merge pull request #1 from syedfakher27/adk-middleware
contextablemark Jul 7, 2025
be845b3
Update documentation and fix session attribute name
mefogle Jul 7, 2025
5c89c7f
Fix test failures: Update attribute name references
mefogle Jul 7, 2025
443ea4d
Fix test failures: Update attribute name references
mefogle Jul 7, 2025
e14f0b6
Fix session manager last_update_time timestamp bug
mefogle Jul 7, 2025
d9d712d
Merge adk-middleware branch to get session manager timestamp fix
mefogle Jul 7, 2025
0e40baa
Add complete bidirectional tool support for ADK middleware
mefogle Jul 7, 2025
64b93f0
Merge pull request #2 from Contextable/feature/tool-support
contextablemark Jul 7, 2025
c053ed6
added tool based generative ui demo
syedfakher27 Jul 8, 2025
f0dea33
print remove
syedfakher27 Jul 8, 2025
e2d06f0
fix tool wrapper test case
syedfakher27 Jul 8, 2025
4b8d173
fix test_endpoint
syedfakher27 Jul 8, 2025
9429aac
test cases fixed
syedfakher27 Jul 8, 2025
05c847e
Update typescript-sdk/integrations/adk-middleware/src/adk_middleware/…
contextablemark Jul 8, 2025
e1fa842
Merge pull request #3 from syedfakher27/adk-middleware
contextablemark Jul 8, 2025
2eb3f28
Release 0.3.2: Hybrid tool execution model with per-tool configuration
mefogle Jul 8, 2025
90deb89
Merge pull request #4 from Contextable/feature/hybrid-tool-execution
contextablemark Jul 8, 2025
5c59fc3
Comprehensive unit test coverage improvements for low-coverage modules
mefogle Jul 8, 2025
eb9d998
Update changelog for improved test coverage
mefogle Jul 8, 2025
64f6a82
Merge pull request #5 from Contextable/improve-unit-test-coverage
contextablemark Jul 8, 2025
eeb47f1
tool submission changes for ADK middleware
syedfakher27 Jul 9, 2025
aae9227
refactor: align tool behavior with ADK standards and fix test coverage
mefogle Jul 9, 2025
0765e9c
Complete ADK middleware test suite fixes - achieve 100% test pass rate
mefogle Jul 10, 2025
4ab8703
Merge pull request #7 from Contextable/refactor-adk-tool-implementation
contextablemark Jul 10, 2025
befc12c
feat: simplify to all-long-running tool architecture with critical bu…
mefogle Jul 11, 2025
517593d
prompt change
syedfakher27 Jul 11, 2025
801bcd7
feat: merge adk-middleware improvements into all-long-running archite…
mefogle Jul 11, 2025
88b1a32
Merge pull request #8 from Contextable/feature/all-long-running-tools…
contextablemark Jul 11, 2025
4a49c62
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Jul 11, 2025
0f7e780
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Jul 12, 2025
520e442
feat: add GitHub Actions CI workflow for ADK middleware
mefogle Jul 13, 2025
e74ffc2
Merge pull request #15 from Contextable/feature/ci-integration
contextablemark Jul 13, 2025
e2bb46b
feat: fix memory persistence and tool ID mapping (v0.4.1)
mefogle Jul 13, 2025
9e39785
Merge pull request #16 from Contextable/feature/memory-bank
contextablemark Jul 13, 2025
077989d
Adding files that were left out of PR #16 and removing unusable workf…
mefogle Jul 13, 2025
dacd7cb
Merge pull request #17 from Contextable/feature/memory-bank
contextablemark Jul 13, 2025
b5b29d5
fix: update test to check debug logging instead of info
mefogle Jul 13, 2025
64ac064
Merge pull request #18 from Contextable/fix/endpoint-logging-test
contextablemark Jul 13, 2025
7cb6b36
shared state demo for dojo app
syedfakher27 Jul 13, 2025
d332319
shared_state_agent added
syedfakher27 Jul 13, 2025
3f464a7
Merge remote-tracking branch 'upstream/adk-middleware' into adk-middl…
syedfakher27 Jul 13, 2025
a956e78
fix: resolve EventType.STATE_DELTA patch error (issue #20)
mefogle Jul 13, 2025
0a2212d
Merge pull request #21 from Contextable/fix/issue-20-state-delta-patc…
contextablemark Jul 13, 2025
58b45bd
feat: add SystemMessage support and fix tool result race condition
mefogle Jul 14, 2025
5975788
Merge pull request #23 from Contextable/feature/system-message-suppor…
contextablemark Jul 14, 2025
5f61634
dojo app backend command added
syedfakher27 Jul 14, 2025
0f00725
session update comments added
syedfakher27 Jul 14, 2025
a37a7fd
Merge remote-tracking branch 'upstream/adk-middleware' into adk-middl…
syedfakher27 Jul 14, 2025
a45eff2
_create_state_delta_event added back
syedfakher27 Jul 14, 2025
365efe0
added memory back again
syedfakher27 Jul 14, 2025
0f35666
simple instructions
syedfakher27 Jul 14, 2025
2f2449c
twice generative AI and HITL fixed
syedfakher27 Jul 14, 2025
e39cd4e
unit test updated for _translate_function_calls
syedfakher27 Jul 14, 2025
0d65159
Update typescript-sdk/integrations/adk-middleware/examples/shared_sta…
syedfakher27 Jul 15, 2025
3e211d0
Update typescript-sdk/integrations/adk-middleware/tests/test_event_tr…
syedfakher27 Jul 15, 2025
74b7f40
Update typescript-sdk/integrations/adk-middleware/examples/fastapi_se…
syedfakher27 Jul 15, 2025
bf4dc54
Update typescript-sdk/integrations/adk-middleware/examples/shared_sta…
syedfakher27 Jul 15, 2025
c7d5e54
Update typescript-sdk/integrations/adk-middleware/examples/shared_sta…
syedfakher27 Jul 15, 2025
ef563f9
Update typescript-sdk/integrations/adk-middleware/src/adk_middleware/…
syedfakher27 Jul 15, 2025
378c642
Update typescript-sdk/integrations/adk-middleware/examples/shared_sta…
syedfakher27 Jul 15, 2025
9339691
Update typescript-sdk/integrations/adk-middleware/examples/fastapi_se…
syedfakher27 Jul 15, 2025
e47627c
test cases for session management added
syedfakher27 Jul 15, 2025
25d3f69
Update typescript-sdk/integrations/adk-middleware/examples/shared_sta…
contextablemark Jul 15, 2025
edc9d25
Update typescript-sdk/integrations/adk-middleware/examples/shared_sta…
contextablemark Jul 15, 2025
1108526
Update typescript-sdk/integrations/adk-middleware/examples/shared_sta…
contextablemark Jul 15, 2025
27b8730
Merge pull request #19 from syedfakher27/adk-middleware
syedfakher27 Jul 15, 2025
aec1385
adk_shared_state_agent fixed
syedfakher27 Jul 15, 2025
4df0a2c
fix: resolve flaky test_bulk_update_user_state_mixed_results
mefogle Jul 17, 2025
81b6c92
Merge pull request #27 from Contextable/fix/flaky-session-test
contextablemark Jul 17, 2025
17b7da5
Merge pull request #26 from syedfakher27/adk-middleware
contextablemark Jul 17, 2025
8d36475
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Jul 19, 2025
bae3bd7
snapshot error fixed
syedfakher27 Jul 20, 2025
1790c4b
function response
syedfakher27 Jul 20, 2025
35047b5
Merge pull request #29 from syedfakher27/adk-middleware
syedfakher27 Jul 20, 2025
24f41a1
Update agent.py
syedfakher27 Jul 21, 2025
a1410c6
Merge remote-tracking branch 'upstream/adk-middleware' into adk-middl…
syedfakher27 Jul 21, 2025
1ff5971
Merge pull request #31 from syedfakher27/adk-middleware
contextablemark Jul 22, 2025
47c8dc3
refactor: use SessionManager methods for pending tool call state mana…
mefogle Jul 24, 2025
ac914b9
removing the print statements
syedfakher27 Jul 26, 2025
3f4342b
long running tool backend handling
syedfakher27 Jul 26, 2025
62da096
update the instruction for the chat demo
syedfakher27 Jul 26, 2025
878cf54
predictive state demo added
syedfakher27 Jul 26, 2025
5e2ec4b
Update typescript-sdk/integrations/adk-middleware/examples/fastapi_se…
syedfakher27 Jul 26, 2025
edd8897
fix: use SessionManager methods for pending tool call state management
mefogle Jul 26, 2025
6d7d558
Merge pull request #34 from Contextable/issue-25-fix
contextablemark Jul 26, 2025
94cf5da
Merge remote-tracking branch 'upstream/adk-middleware' into adk-middl…
syedfakher27 Jul 26, 2025
ac2830a
backend tool pending issue fixed
syedfakher27 Jul 26, 2025
34be480
Update Changelog.md
syedfakher27 Jul 26, 2025
cf9d1c0
TestEventTranslatorComprehensive tests fixed
syedfakher27 Jul 26, 2025
b9b85e1
recipe prompt change
syedfakher27 Jul 29, 2025
626d9ba
model updated for human in loop
syedfakher27 Jul 30, 2025
5243567
Initial documentation changes
contextablemark Aug 2, 2025
20bce0b
Merge branch 'main' into adk-middleware
contextablemark Aug 2, 2025
1f9da91
feat: eliminate AgentRegistry and implement direct agent embedding
mefogle Aug 2, 2025
f45b00e
docs: update documentation to remove AgentRegistry references
mefogle Aug 2, 2025
14bab93
stopping condition added
syedfakher27 Aug 5, 2025
527c112
feat: make session_service configurable in ADKAgent constructor
mefogle Aug 5, 2025
8e13a52
print statement removed
syedfakher27 Aug 5, 2025
d5ddc14
Merge pull request #33 from syedfakher27/adk-middleware
contextablemark Aug 5, 2025
c1e5b53
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 5, 2025
f897d0b
Merge branch 'adk-middleware' into issue-24-cleanup-agent-registration
contextablemark Aug 5, 2025
0330453
Removing registry entries and redundant constructor.
mefogle Aug 5, 2025
82b4395
Added support for agentFilesMapper.
mefogle Aug 5, 2025
ceec7e6
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 5, 2025
849ca93
Merge branch 'adk-middleware' into issue-24-cleanup-agent-registration
mefogle Aug 5, 2025
848b465
Fix ADKAgent test suite for new architecture
mefogle Aug 5, 2025
5d16bb1
Merge pull request #36 from Contextable/issue-24-cleanup-agent-regist…
contextablemark Aug 5, 2025
e821ba4
Added in updated file content.
mefogle Aug 5, 2025
20d8971
Merge pull request #40 from Contextable/issue-24-cleanup-agent-regist…
contextablemark Aug 5, 2025
c4c175e
Add e2e tests for ADK middleware agentic chat
mefogle Aug 6, 2025
629cfe0
Merge pull request #41 from Contextable/feature/adk-e2e-tests
contextablemark Aug 6, 2025
bea6ef9
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 6, 2025
2aec7e0
feat: Make ADK middleware base URL configurable via environment variable
mefogle Aug 7, 2025
cedc747
Merge pull request #43 from Contextable/railway
contextablemark Aug 7, 2025
9924908
feat: Upgrade Google ADK dependency to 1.9.0
mefogle Aug 7, 2025
e04c063
Merge pull request #44 from Contextable/adk-upgrade
contextablemark Aug 7, 2025
5e54f15
Merge branch 'adk-middleware' into issue-35
contextablemark Aug 7, 2025
9a1b9ce
docs: Extensive documentation restructuring for improved organization
mefogle Aug 7, 2025
3313c27
Merge pull request #45 from Contextable/issue-35
contextablemark Aug 7, 2025
97996a2
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 7, 2025
41660e5
fix: support instructions provider for agents
evgeny-l Aug 8, 2025
0c1fd6d
fix: support of before_agent_callback in case of a direct content res…
evgeny-l Aug 8, 2025
70aa99e
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 11, 2025
b7063c6
Added aiohttp dependency.
mefogle Aug 12, 2025
4b3207c
Merge pull request #50 from Contextable/aiohttp_issue
contextablemark Aug 12, 2025
b7aca0f
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 14, 2025
4ce24b9
- General cleanup
mefogle Aug 14, 2025
7abe5b9
Merge pull request #52 from Contextable/general-cleanup
contextablemark Aug 14, 2025
27a9925
Update typescript-sdk/integrations/adk-middleware/src/adk_middleware/…
evgeny-l Aug 14, 2025
9d418d3
Update typescript-sdk/integrations/adk-middleware/tests/test_text_eve…
evgeny-l Aug 14, 2025
60bd9a1
fix: support of before_agent_callback in case of a direct content res…
evgeny-l Aug 14, 2025
4255743
fix: support instructions provider for agents - handle sync cases and…
evgeny-l Aug 14, 2025
446f2e9
Merge pull request #49 from evgeny-l/adk-middleware-before-agent-call…
contextablemark Aug 14, 2025
f20257f
Merge pull request #48 from evgeny-l/adk-middleware-instructions-prov…
contextablemark Aug 14, 2025
c1596c9
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 16, 2025
aaae5da
fix: update tests to match new logging levels from PR #49
contextablemark Aug 16, 2025
0835b5b
Merge pull request #53 from Contextable/fix/test-logging-levels
contextablemark Aug 16, 2025
3b84edd
fix: change misleading 'Session not found' warnings to debug messages
contextablemark Aug 19, 2025
856fac3
Merge pull request #54 from Contextable/fix/session-not-found-warning
contextablemark Aug 19, 2025
e4ffff6
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 24, 2025
00f3b5f
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 27, 2025
6703c09
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Aug 29, 2025
bff1b59
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Sep 3, 2025
3d54ae7
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Sep 9, 2025
d6e083d
Merge branch 'ag-ui-protocol:main' into adk-middleware
contextablemark Sep 15, 2025
9334451
fix: make error handling test more robust
contextablemark Sep 15, 2025
bb3e812
Merge pull request #68 from Contextable/fix/test-error-handling
contextablemark Sep 15, 2025
d3d2054
feat: upgrade Google ADK requirement to >=1.14.0
contextablemark Sep 15, 2025
f73d20b
Merge pull request #69 from Contextable/update/adk-latest-version
contextablemark Sep 15, 2025
b8b9071
feat: optimize session state management with dictionary-based lookups
contextablemark Sep 15, 2025
c5dd37c
Merge pull request #71 from Contextable/fix/session-state-management-…
contextablemark Sep 15, 2025
aaac172
refactor: remove redundant execution checks in _start_new_execution
contextablemark Sep 15, 2025
a89a8cd
Merge pull request #73 from Contextable/refactor/remove-redundant-exe…
contextablemark Sep 15, 2025
aa9368d
move examples folder out before refactor
maxkorp Sep 16, 2025
c203e3e
New examples folder
maxkorp Sep 16, 2025
667ab7f
Add creds check
maxkorp Sep 16, 2025
24914ee
delete moved code
maxkorp Sep 16, 2025
f0f7bd4
move remaining examples2 to examples/other
maxkorp Sep 16, 2025
7c90e4e
make haiku generator more flexible
maxkorp Sep 16, 2025
6f6067f
fixup docs route
maxkorp Sep 16, 2025
96fbff9
codegen
maxkorp Sep 16, 2025
6db3741
Restructure adk examples to use uv
maxkorp Sep 16, 2025
ad28e3d
Merge remote-tracking branch 'origin/adk-middleware' into adk-middleware
maxkorp Sep 16, 2025
ca7f08d
Fix HITL examples via prompt
maxkorp Sep 16, 2025
cced002
Merge remote-tracking branch 'origin/main' into adk-middleware
maxkorp Sep 16, 2025
5bac82f
Migrate e2e tests from old e2e2 package
maxkorp Sep 16, 2025
2680589
fix agentic chat tests with prompting
maxkorp Sep 16, 2025
6b8a1aa
fix irrelevant testcase
maxkorp Sep 16, 2025
d7ba909
wrap all e2e in descriptors
maxkorp Sep 16, 2025
10720e5
update genned docs
maxkorp Sep 16, 2025
5c2329f
fix absolute path
maxkorp Sep 16, 2025
f5b8514
disable predictive state for now
maxkorp Sep 16, 2025
f1c4531
Merge pull request #74 from ag-ui-protocol/adk-middleware
contextablemark Sep 16, 2025
ea51575
Update README.md
contextablemark Sep 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

4 changes: 0 additions & 4 deletions typescript-sdk/integrations/adk-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enhanced tool call ID extraction from ADK context for proper protocol bridging
- Cleaned up debug logging statements throughout codebase

### Added (Previous Release)
- GitHub Actions CI workflow for automated testing on pull requests
- CI runs pytest for all 185 tests when ADK middleware files are modified
- Path-specific triggering to avoid unnecessary test runs

## [0.4.0] - 2025-07-11

Expand Down
62 changes: 62 additions & 0 deletions typescript-sdk/integrations/adk-middleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,68 @@ agent = ADKAgent(
- **Comprehensive**: Applies to all session deletions (timeout, user limits, manual)
- **Performance**: Preserves conversation history without manual intervention

### Memory Tools Integration

To enable memory functionality in your ADK agents, you need to add Google ADK's memory tools to your agents (not to the ADKAgent middleware):

```python
from google.adk.agents import Agent
from google.adk import tools as adk_tools

# Create agent with memory tools - THIS IS CORRECT
my_agent = Agent(
name="assistant",
model="gemini-2.0-flash",
instruction="You are a helpful assistant.",
tools=[adk_tools.preload_memory_tool.PreloadMemoryTool()] # Add memory tools here
)

# Register the agent
registry = AgentRegistry.get_instance()
registry.set_default_agent(my_agent)

# Create middleware WITHOUT tools parameter - THIS IS CORRECT
adk_agent = ADKAgent(
app_name="my_app",
user_id="user123",
memory_service=shared_memory_service # Memory service enables automatic session memory
)
```

**⚠️ Important**: The `tools` parameter belongs to the ADK agent (like `Agent` or `LlmAgent`), **not** to the `ADKAgent` middleware. The middleware automatically handles any tools defined on the registered agents.

### Memory Testing Configuration

For testing memory functionality across sessions, you may want to shorten the default session timeouts:

```python
# Normal production settings (default)
adk_agent = ADKAgent(
app_name="my_app",
user_id="user123",
memory_service=shared_memory_service
# session_timeout_seconds=1200, # 20 minutes (default)
# cleanup_interval_seconds=300 # 5 minutes (default)
)

# Short timeouts for memory testing
adk_agent = ADKAgent(
app_name="my_app",
user_id="user123",
memory_service=shared_memory_service,
session_timeout_seconds=60, # 1 minute for quick testing
cleanup_interval_seconds=30 # 30 seconds cleanup for quick testing
)
```

**Testing Memory Workflow:**
1. Start a conversation and provide information (e.g., "My name is John")
2. Wait for session timeout + cleanup interval (up to 90 seconds with testing config: 60s timeout + up to 30s for next cleanup cycle)
3. Start a new conversation and ask about the information ("What's my name?")
4. The agent should remember the information from the previous session

**⚠️ Note**: Always revert to production timeouts (defaults) for actual deployments.

## Tool Support

The middleware provides complete bidirectional tool support, enabling AG-UI Protocol tools to execute within Google ADK agents through an advanced **hybrid execution model** that bridges AG-UI's stateless runs with ADK's stateful execution.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python
"""Complete setup example for ADK middleware with AG-UI."""

import sys
import logging
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))

import asyncio
import uvicorn
Expand All @@ -19,20 +16,26 @@

# Configure component-specific logging levels using standard Python logging
# Can be overridden with PYTHONPATH or programmatically
logging.getLogger('adk_agent').setLevel(logging.DEBUG)
logging.getLogger('adk_agent').setLevel(logging.WARNING)
logging.getLogger('event_translator').setLevel(logging.WARNING)
logging.getLogger('endpoint').setLevel(logging.DEBUG) # Changed to INFO for debugging
logging.getLogger('endpoint').setLevel(logging.WARNING)
logging.getLogger('session_manager').setLevel(logging.WARNING)
logging.getLogger('agent_registry').setLevel(logging.DEBUG) # Changed to INFO for debugging
logging.getLogger('agent_registry').setLevel(logging.WARNING)

# from adk_agent import ADKAgent
# from agent_registry import AgentRegistry
# from endpoint import add_adk_fastapi_endpoint
from adk_middleware import ADKAgent, AgentRegistry, add_adk_fastapi_endpoint
# Import Google ADK components
from google.adk.agents import Agent
from google.adk import tools as adk_tools
import os

# Ensure session_manager logger is set to DEBUG after import
logging.getLogger('adk_middleware.session_manager').setLevel(logging.DEBUG)
# Also explicitly set adk_agent logger to DEBUG
logging.getLogger('adk_middleware.adk_agent').setLevel(logging.DEBUG)


async def setup_and_run():
"""Complete setup and run the server."""
Expand All @@ -47,7 +50,12 @@ async def setup_and_run():
# The API key will be automatically picked up from the environment


# Step 2: Create your ADK agent(s)
# Step 2: Create shared memory service
print("🧠 Creating shared memory service...")
from google.adk.memory import InMemoryMemoryService
shared_memory_service = InMemoryMemoryService()

# Step 3: Create your ADK agent(s)
print("🤖 Creating ADK agents...")

# Create a versatile assistant
Expand All @@ -62,10 +70,10 @@ async def setup_and_run():
- Provide step-by-step explanations
- Admit when you don't know something

Always be friendly and professional."""
Always be friendly and professional.""",
tools=[adk_tools.preload_memory_tool.PreloadMemoryTool()]
)


# Step 3: Register agents
print("📝 Registering agents...")
registry = AgentRegistry.get_instance()
Expand Down Expand Up @@ -110,7 +118,7 @@ def extract_user_id(input_data):
for ctx in input_data.context:
if ctx.description == "user":
return ctx.value
return f"anonymous_{input_data.thread_id}"
return "test_user" # Static user ID for memory testing

def extract_app_name(input_data):
"""Extract app name from context."""
Expand All @@ -122,10 +130,10 @@ def extract_app_name(input_data):
adk_agent = ADKAgent(
app_name_extractor=extract_app_name,
user_id_extractor=extract_user_id,
use_in_memory_services=True
# Uses default session manager with 20 min timeout, auto cleanup enabled
use_in_memory_services=True,
memory_service=shared_memory_service, # Use the same memory service as the ADK agent
# Defaults: 1200s timeout (20 min), 300s cleanup (5 min)
)


# Step 5: Create FastAPI app
print("🌐 Creating FastAPI app...")
Expand Down Expand Up @@ -198,7 +206,7 @@ async def list_agents():
print("\n✅ Setup complete! Starting server...\n")
print("🔗 Chat endpoint: http://localhost:8000/chat")
print("📚 API documentation: http://localhost:8000/docs")
print("🔍 Health check: http://localhost:8000/health")
print("🏥 Health check: http://localhost:8000/health")
print("\n🔧 Logging Control:")
print(" # Set logging level for specific components:")
print(" logging.getLogger('event_translator').setLevel(logging.DEBUG)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from adk_middleware import ADKAgent, AgentRegistry, add_adk_fastapi_endpoint
from google.adk.agents import LlmAgent
from google.adk import tools as adk_tools

# Set up the agent registry
registry = AgentRegistry.get_instance()
Expand All @@ -27,7 +28,8 @@
sample_agent = LlmAgent(
name="assistant",
model="gemini-2.0-flash",
instruction="You are a helpful assistant."
instruction="You are a helpful assistant.",
tools=[adk_tools.preload_memory_tool.PreloadMemoryTool()]
)

# Register the agent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Core dependencies
ag-ui-protocol>=0.1.7
google-adk>=1.5.0
google-adk>=1.6.1
pydantic>=2.11.7
asyncio>=3.4.3
fastapi>=0.115.2
Expand Down
2 changes: 1 addition & 1 deletion typescript-sdk/integrations/adk-middleware/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
python_requires=">=3.8",
install_requires=[
"ag-ui-protocol>=0.1.7",
"google-adk>=1.5.0",
"google-adk>=1.6.1",
"pydantic>=2.11.7",
"asyncio>=3.4.3",
"fastapi>=0.115.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@
import logging
logger = logging.getLogger(__name__)

# Set up debug logging
if not logger.handlers:
handler = logging.StreamHandler()
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)


class ADKAgent:
Expand Down Expand Up @@ -75,7 +67,10 @@ def __init__(
# Tool configuration
execution_timeout_seconds: int = 600, # 10 minutes
tool_timeout_seconds: int = 300, # 5 minutes
max_concurrent_executions: int = 10
max_concurrent_executions: int = 10,

# Session cleanup configuration
cleanup_interval_seconds: int = 300 # 5 minutes default
):
"""Initialize the ADKAgent.

Expand Down Expand Up @@ -129,9 +124,9 @@ def __init__(

self._session_manager = SessionManager.get_instance(
session_service=session_service,
memory_service=memory_service, # Pass memory service for automatic session memory
memory_service=self._memory_service, # Pass memory service for automatic session memory
session_timeout_seconds=session_timeout_seconds, # 20 minutes default
cleanup_interval_seconds=300, # 5 minutes default
cleanup_interval_seconds=cleanup_interval_seconds,
max_sessions_per_user=None, # No limit by default
auto_cleanup=True # Enable by default
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@

logger = logging.getLogger(__name__)

# Set up debug logging
if not logger.handlers:
handler = logging.StreamHandler()
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)


class ClientProxyTool(BaseTool):
Expand Down Expand Up @@ -111,9 +103,6 @@ def _get_declaration(self) -> Optional[types.FunctionDeclaration]:
# Convert AG-UI parameters (JSON Schema) to ADK format
parameters = self.ag_ui_tool.parameters

# Debug: Show the raw parameters
print(f"🔍 TOOL PARAMS DEBUG: Tool '{self.ag_ui_tool.name}' parameters: {parameters}")
print(f"🔍 TOOL PARAMS DEBUG: Parameters type: {type(parameters)}")

# Ensure it's a proper object schema
if not isinstance(parameters, dict):
Expand Down Expand Up @@ -161,11 +150,20 @@ async def _execute_proxy_tool(self, args: Dict[str, Any], tool_context: Any) ->
Returns:
None for long-running tools
"""
logger.debug(f"🛠️ PROXY TOOL EXECUTION: {self.ag_ui_tool.name}")
logger.debug(f"🛠️ Arguments received: {args}")
logger.debug(f"Proxy tool execution: {self.ag_ui_tool.name}")
logger.debug(f"Arguments received: {args}")
logger.debug(f"Tool context type: {type(tool_context)}")

# Generate a unique tool call ID
tool_call_id = f"call_{uuid.uuid4().hex[:8]}"
# Extract ADK-generated function call ID if available
adk_function_call_id = None
if tool_context and hasattr(tool_context, 'function_call_id'):
adk_function_call_id = tool_context.function_call_id
logger.debug(f"Using ADK function_call_id: {adk_function_call_id}")

# Use ADK ID if available, otherwise fall back to generated ID
tool_call_id = adk_function_call_id or f"call_{uuid.uuid4().hex[:8]}"
if not adk_function_call_id:
logger.warning(f"ADK function_call_id not available, generated: {tool_call_id}")

try:
# Emit TOOL_CALL_START event
Expand All @@ -175,7 +173,7 @@ async def _execute_proxy_tool(self, args: Dict[str, Any], tool_context: Any) ->
tool_call_name=self.ag_ui_tool.name
)
await self.event_queue.put(start_event)
logger.debug(f"🛠️ Emitted TOOL_CALL_START for {tool_call_id}")
logger.debug(f"Emitted TOOL_CALL_START for {tool_call_id}")

# Emit TOOL_CALL_ARGS event
args_json = json.dumps(args)
Expand All @@ -185,22 +183,22 @@ async def _execute_proxy_tool(self, args: Dict[str, Any], tool_context: Any) ->
delta=args_json
)
await self.event_queue.put(args_event)
logger.debug(f"🛠️ Emitted TOOL_CALL_ARGS for {tool_call_id}")
logger.debug(f"Emitted TOOL_CALL_ARGS for {tool_call_id}")

# Emit TOOL_CALL_END event
end_event = ToolCallEndEvent(
type=EventType.TOOL_CALL_END,
tool_call_id=tool_call_id
)
await self.event_queue.put(end_event)
logger.debug(f"🛠️ Emitted TOOL_CALL_END for {tool_call_id}")
logger.debug(f"Emitted TOOL_CALL_END for {tool_call_id}")

# Return None for long-running tools - client handles the actual execution
logger.debug(f"🛠️ Returning None for long-running tool {tool_call_id}")
logger.debug(f"Returning None for long-running tool {tool_call_id}")
return None

except Exception as e:
logger.error(f"🛠️ Error in proxy tool execution for {tool_call_id}: {e}")
logger.error(f"Error in proxy tool execution for {tool_call_id}: {e}")
raise

def __repr__(self) -> str:
Expand Down
Loading