Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 0 additions & 13 deletions taosmd/__main__.py

This file was deleted.

8 changes: 8 additions & 0 deletions taosmd/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,17 @@ def _dispatch(self, method: str) -> None:
self._handle_a2a_members(query)
elif method == "GET" and path == "/a2a/messages":
self._handle_a2a_messages(query)
elif method == "GET" and path == "/a2a/threads":
self._handle_a2a_threads(query)
elif method == "GET" and path.startswith("/a2a/threads/") and "/messages" in path:
self._handle_a2a_thread_messages(query)
Comment on lines +956 to +959

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm whether the routed handlers exist anywhere in the repo.
rg -nP --type=py '\bdef\s+_handle_a2a_thread(s|_messages)\s*\(' -C2

# Show every reference to the handler names.
rg -nP --type=py '_handle_a2a_thread(s|_messages)\b' -C1

# Confirm the RemoteClient side of the contract exists too.
rg -nP --type=py '\b(async\s+)?def\s+a2a_thread(s|_messages)\s*\(' -C3

Repository: jaylfc/taosmd

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -u

echo "== candidate files =="
git ls-files '*.py' | sed -n '1,200p'

echo "== handler references =="
rg -n --type=py '_handle_a2a_thread|a2a_thread(s|_messages)\b|a2a_threads\b' -C2 .

echo "== http_server relevant sections =="
for f in $(git ls-files '*.py' | rg '(^|/)http_server\.py$|(^|/)service\.py$|taosmd/'); do
  if [ -f "$f" ]; then
    echo "--- $f outline/matches ---"
    rg -n 'class TaosmdHandler|def do_GET|def _handle_a2a|a2a_thread_messages|a2a_threads|before="|after="|limit=' "$f" -C3 || true
  fi
done

Repository: jaylfc/taosmd

Length of output: 40229


🏁 Script executed:

#!/bin/bash
set -u

echo "== http_server TaosmdHandler class range =="
wc -l taosmd/http_server.py
sed -n '920,1085p' taosmd/http_server.py | cat -n

echo "== a2a message handler params/validation =="
sed -n '1512,1534p' taosmd/http_server.py | cat -n

echo "== task/collection path parsing examples =="
sed -n '967,995p' taosmd/http_server.py | cat -n
rg -n --type=py '_handle_task(_[a-z_]+)?\b|_handle_collection(_[a-z_]+)?\b|collections/' taosmd/http_server.py -C3

echo "== service a2a_thread_messages signature/body =="
sed -n '727,790p' taosmd/service.py | cat -n
sed -n '1362,1405p' taosmd/service.py | cat -n

echo "== remote a2a thread methods =="
rg -n --type=py 'a2a_threads|a2a_thread_messages|thread' taosmd/remote.py -C4

Repository: jaylfc/taosmd

Length of output: 32743


🏁 Script executed:

#!/bin/bash
set -u

echo "== handler definitions =="
rg -n --type=py '\bdef\s+_handle_([^(\s]+)' taosmd/http_server.py | sed -n '900,1000p'

echo "== exact method existence check =="
python3 - <<'PY'
from pathlib import Path
src = Path('taosmd/http_server.py').read_text()
for needle in ['def _handle_a2a_threads', 'def _handle_a2a_thread_messages', 'def _handle_task_create', 'def _handle_task_update']:
    print(needle, 'FOUND' if needle in src else 'NOT FOUND')
PY

Repository: jaylfc/taosmd

Length of output: 348


Add the A2A thread routes before exposing them.

_handle_a2a_threads and _handle_a2a_thread_messages are referenced from the TaosmdHandler routing but are not defined in taosmd/http_server.py, so any request to these routes can escape to the generic exception handler and return 500. Implement these handlers or remove the routes. For the per-thread messages route, also parse the URL-decoded thread segment and pass it to service.a2a_thread_messages, whose signature requires thread plus before/after/limit.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@taosmd/http_server.py` around lines 956 - 959, Implement the missing
TaosmdHandler methods _handle_a2a_threads and _handle_a2a_thread_messages, or
remove their routing branches. For the per-thread messages handler, URL-decode
and extract the thread segment, then call service.a2a_thread_messages with
thread, before, after, and limit parameters; ensure both routes return their
service results through the existing response flow.

Comment on lines +956 to +959

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Missing thread handlers 🐞 Bug ≡ Correctness

http_server._dispatch routes GET /a2a/threads and /a2a/threads/{thread}/messages to
_handle_a2a_threads/_handle_a2a_thread_messages, but those handlers are not defined, so matching
requests raise AttributeError and fail with a 500.
Agent Prompt
### Issue description
`taosmd/http_server.py` dispatches the new A2A thread endpoints to handler methods that do not exist (`_handle_a2a_threads`, `_handle_a2a_thread_messages`). Any request to these routes will crash with `AttributeError` and return a 500.

### Issue Context
The server already implements `_handle_a2a_messages` and `_handle_a2a_stream` and wires them via `_dispatch`. The new routes must follow the same pattern (parse query/path params, call `service.a2a_threads` / `service.a2a_thread_messages`, and `_send_json`).

### Fix Focus Areas
- taosmd/http_server.py[953-966]
- taosmd/http_server.py[1512-1603]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

elif method == "GET" and path == "/a2a/stream":
self._handle_a2a_stream(query)
return # SSE response already sent; skip _send_json error path
elif method == "GET" and path == "/a2a/threads":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Duplicate route registration — /a2a/threads and /a2a/threads/{thread}/messages routes are registered twice (lines 956–959 and 963–966). The second registration is unreachable dead code.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

self._handle_a2a_threads(query)
elif method == "GET" and path.startswith("/a2a/threads/") and "/messages" in path:
self._handle_a2a_thread_messages(query)
Comment on lines 960 to +966

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Lines 963-966 are unreachable duplicates of Lines 956-959.

The same two elif conditions appear twice in one chain; the second pair can never be evaluated. Delete it.

🧹 Proposed fix
                 elif method == "GET" and path == "/a2a/stream":
                     self._handle_a2a_stream(query)
                     return  # SSE response already sent; skip _send_json error path
-                elif method == "GET" and path == "/a2a/threads":
-                    self._handle_a2a_threads(query)
-                elif method == "GET" and path.startswith("/a2a/threads/") and "/messages" in path:
-                    self._handle_a2a_thread_messages(query)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
elif method == "GET" and path == "/a2a/stream":
self._handle_a2a_stream(query)
return # SSE response already sent; skip _send_json error path
elif method == "GET" and path == "/a2a/threads":
self._handle_a2a_threads(query)
elif method == "GET" and path.startswith("/a2a/threads/") and "/messages" in path:
self._handle_a2a_thread_messages(query)
elif method == "GET" and path == "/a2a/stream":
self._handle_a2a_stream(query)
return # SSE response already sent; skip _send_json error path
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@taosmd/http_server.py` around lines 960 - 966, Remove the duplicate GET route
branches for "/a2a/threads" and "/a2a/threads/" messages from the
request-dispatch chain, preserving the earlier handlers and the "/a2a/stream"
SSE behavior.

Comment on lines +963 to +966

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

6. Duplicate thread code paths 🐞 Bug ⚙ Maintainability

The PR introduces duplicated /a2a/threads routing branches and duplicate definitions of
a2a_threads/a2a_thread_messages in service.py; one set becomes unreachable/overridden, increasing
the risk that future fixes are applied to the wrong copy.
Agent Prompt
### Issue description
There are duplicated code paths for the new thread endpoints:
- `_dispatch` contains two identical `elif` blocks for `/a2a/threads` and `/a2a/threads/.../messages`.
- `service.py` defines `a2a_threads` and `a2a_thread_messages` twice; Python keeps only the later definitions, leaving the earlier copies as dead code.

This is confusing for maintainers and makes it easy to patch the wrong copy.

### Issue Context
Cleaning this up will also make it much easier to correctly implement the endpoints and add tests.

### Fix Focus Areas
- taosmd/http_server.py[955-966]
- taosmd/service.py[628-853]
- taosmd/service.py[1260-1478]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

# Task graph endpoints — prefix matching for /tasks/{id} paths
elif method == "POST" and path == "/tasks":
self._handle_task_create()
Expand Down
Loading