Add optional automatic tool naming#51
Conversation
|
Update after conflict-reduction pass:
Validation for this follow-up:
Note: Pairwise merge status after this update:
|
|
The E2E failure is caused by a selector expectation that no longer matches the trace selection UI. The failing test is Could the test be updated to select tools through the current row interaction, or better, through a stable test id / accessible selector that represents the selectable tool row instead of assuming each include control is a button named Code and PR drafted with Codex. |
jasonmadigan
left a comment
There was a problem hiding this comment.
thanks for putting this together. the implementation is thorough and the UX flow (generic labels first, stream in names, allow manual override) is well thought out.
a few things to discuss before we move forward on the code:
direction concern
tool naming/categorisation should be optional and pluggable, not tied to a specific inference approach. this PR bakes in four provider backends (Ollama, Gemini, OpenRouter, hosted fallback) with warmup, polling, retry, and background task infrastructure. that's a lot of surface area for what should be one possible implementation behind a simple interface. I'd rather see a clean abstraction (e.g. a ToolNamer protocol with a single name(image) -> str method) that this ML approach can plug into, alongside simpler alternatives (manual-only, filename-based, etc).
code-level findings (for when the direction is agreed)
- 3 of 21 new tests fail --
test_background_labeling_*tests pass"default"(string) whereSessionStoreis expected. the outertry/exceptswallows theAttributeError, so some tests pass by accident asyncio.create_task()with no stored reference -- task can be silently GC'd- multiple
ToolLabeler()instantiations per request (re-reads settings each time) os.getenv()alongside pydantic-settings creates double source of truth for config- 500ms polling (40 attempts) -- consider SSE or a lightweight status endpoint
happy to discuss the architecture direction. I've added a DESIGN.md to capture these kinds of decisions so we're aligned before PRs get too far along.
|
Hey, sorry for this one. I intended to keep it optional/pluggable but the implementation got complicated over time and I didn't consider how impactful it was by the time I finished. I'll rework this and follow your direction and fix those other things. Do you want me to share extra info before I re-submit a PR, or push to my fork or something? |
Reworks the rejected upstream PR tracefinity#51 to address the maintainer's direction and code-level feedback. Naming is now a small pluggable capability instead of bespoke multi-provider background infrastructure: - `ToolNamer` protocol (`name(image) -> str | None`) with a single `GeminiToolNamer` implementation that reuses the existing Gemini / OpenRouter label model. Any namer (local VLM, heuristic, test stub) can plug in without touching callers. - `get_tool_namer()` reads app config (pydantic-settings) as the single source of truth — no `os.getenv` second source. - On-demand `POST /sessions/{id}/name-tools` endpoint names crops synchronously with `asyncio.gather` — no background `create_task` (no GC risk), no warm-up, no 500ms polling. One namer per request. - Frontend: a user-triggered "Auto-name tools" button in the Select Tools step (shown only when a backend is available), plus inline editable tool names so users can correct before saving. Naming is strictly optional: the button only appears when a Gemini / OpenRouter key is available, and failures are swallowed so the trace flow is never blocked. Adds real unit tests for name normalisation, backend selection, the protocol, and error handling. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
3f4fe52 to
3d1b156
Compare
|
I reworked this to follow the optional/pluggable direction more closely. The branch now removes the provider-heavy/background naming surface and keeps the PR focused on a small foundation:
I also squashed the branch to one commit over current |
3d1b156 to
c9ef7b5
Compare
jasonmadigan
left a comment
There was a problem hiding this comment.
nice rework, much cleaner. one thing worth fixing:
# Conflicts: # backend/app/api/routes.py
|
Updated the branch for the latest Changes:
Validation:
Code and PR drafted with Codex |
Summary
ToolNamerabstraction.tool Nlabels when naming is unavailable or returns an unusable result.docs/tool-naming.md.Why
This keeps automatic naming optional and pluggable without making the trace workflow depend on model availability or hosted providers. The trace result remains immediately usable with generic labels, and naming failures do not block saving tools.
Validation
python -m pytest backend/tests/test_ort_runtime.py- passed, 6 tests.python -m pytest backend/tests/test_tool_namer.py- passed, 12 tests.python -m pytest backend/tests- collection reached 172 tests, then stopped on an unrelated existing collection error inbackend/tests/test_image_downscale.py: it imports_downscale_imagefromapp.api.routes, which is not exported on this branch/base.git diff --check- passed.TRACEFINITY_ONNX_GPU_MEM_LIMIT_MB,TRACEFINITY_ONNX_ARENA_EXTEND_STRATEGY, or their helper functions.Codex Disclaimer
Code and PR drafted with Codex