Skip to content

Commit 29630d5

Browse files
authored
Merge pull request #59 from eddiedunn/codex/document-functions-in-router/main.py-and-local_agent/main.py
Add missing docstrings
2 parents b8cd160 + 00af529 commit 29630d5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

local_agent/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ async def _post_with_retry(path: str, payload: dict) -> None:
4747

4848

4949
async def register_with_router() -> None:
50+
"""Register this agent with the router service."""
51+
5052
payload = {
5153
"name": AGENT_NAME,
5254
"endpoint": AGENT_ENDPOINT,
@@ -56,19 +58,25 @@ async def register_with_router() -> None:
5658

5759

5860
async def heartbeat_loop() -> None:
61+
"""Send regular heartbeat messages to the router."""
62+
5963
while True:
6064
await _post_with_retry("/heartbeat", {"name": AGENT_NAME})
6165
await asyncio.sleep(HEARTBEAT_INTERVAL)
6266

6367

6468
@app.on_event("startup")
6569
async def _startup() -> None:
70+
"""Start background registration and heartbeat tasks."""
71+
6672
asyncio.create_task(register_with_router())
6773
asyncio.create_task(heartbeat_loop())
6874

6975

7076
@app.post("/infer")
7177
async def infer(payload: ChatCompletionRequest):
78+
"""Return a trivial echo response for the given request."""
79+
7280
user_msg = payload.messages[-1].content if payload.messages else ""
7381
content = f"Echo: {user_msg}"
7482
response = {

router/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108

109109

110110
async def cache_get(key: str) -> str | None:
111+
"""Return cached value if present and not expired."""
112+
111113
entry = CACHE_STORE.get(key)
112114
if entry is None:
113115
return None
@@ -119,6 +121,8 @@ async def cache_get(key: str) -> str | None:
119121

120122

121123
async def cache_set(key: str, value: str, ttl: int = CACHE_TTL) -> None:
124+
"""Store a value in the cache for ``ttl`` seconds."""
125+
122126
CACHE_STORE[key] = (time.time() + ttl, value)
123127

124128

0 commit comments

Comments
 (0)