Skip to content

refactor(tools): move tool descriptions to jinja templates#2177

Closed
nikhilk7153 wants to merge 10 commits intoOpenHands:mainfrom
nikhilk7153:feat/tools-j2-descriptions
Closed

refactor(tools): move tool descriptions to jinja templates#2177
nikhilk7153 wants to merge 10 commits intoOpenHands:mainfrom
nikhilk7153:feat/tools-j2-descriptions

Conversation

@nikhilk7153
Copy link
Copy Markdown

@nikhilk7153 nikhilk7153 commented Feb 23, 2026

Fix #2129

Summary

  • move tool definition descriptions from inline Python strings into packaged .j2 templates across openhands-tools
  • render descriptions at tool creation time to preserve dynamic context (for example, working directory and vision-aware variants)
  • keep tool behavior and schemas unchanged while making prompt text easier to maintain

nikhilk7153 and others added 3 commits February 23, 2026 01:23
Move tool definition description text into packaged .j2 files and render them at tool creation time to simplify maintenance while preserving runtime behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
Include new tool .j2 template paths in the PyInstaller spec so agent-server binaries can load tool descriptions at runtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
@all-hands-bot all-hands-bot requested a review from enyst February 25, 2026 12:30
@all-hands-bot
Copy link
Copy Markdown
Collaborator

[Automatic Post]: I have assigned @enyst as a reviewer based on git blame information. Thanks in advance for the help!

@all-hands-bot
Copy link
Copy Markdown
Collaborator

[Automatic Post]: This PR seems to be currently waiting for review. @enyst, could you please take a look when you have a chance?

@enyst
Copy link
Copy Markdown
Collaborator

enyst commented Mar 8, 2026

@OpenHands Read the linked issue and understand this PR. Then, choose an example or two to run, which contain tools, from the examples/ directory, and run them, to see if they work normally.

You can use openai key and gpt-5-nano, I think, just a small llm for testing.

Then, once you are done, do a /codereview too, and publish it with your feedback (not a comment, you are allowed to review). Include the results.

@openhands-ai
Copy link
Copy Markdown

openhands-ai bot commented Mar 8, 2026

I'm on it! enyst can track my progress at all-hands.dev

Copy link
Copy Markdown
Collaborator

@enyst enyst left a comment

Choose a reason for hiding this comment

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

Review summary

No blocking issues found. The template extraction and render-time description wiring look consistent across tools, and packaging updates include new templates.

Testing

  • LLM_API_KEY=$OPENAI_API_KEY LLM_MODEL=openai/gpt-5-nano uv run python examples/01_standalone_sdk/02_custom_tools.py
  • LLM_API_KEY=$OPENAI_API_KEY LLM_MODEL=openai/gpt-5-nano uv run python examples/01_standalone_sdk/41_task_tool_set.py

Notes

  • This PR changes prompt/tool description text. Per repo guidance, please add the integration-test label (or run the integration suite) to validate eval behavior.

@openhands-ai

This comment was marked as duplicate.

Co-authored-by: openhands <openhands@all-hands.dev>
Copy link
Copy Markdown
Collaborator

enyst commented Mar 8, 2026

Tool description comparison results are now checked in under .pr/:

  • .pr/tool-description-compare-results.md (summary + commands)
  • .pr/tool-description-diff.md (full unified diffs)

Summary of detected text changes (main → PR):

  • apply_patch: single-line description becomes two lines (line break).
  • grep: example regex now renders with double backslashes (\\s+\\w+).
  • file_editor / planning_file_editor (vision enabled): image-viewing bullet moves above the text-file bullet; extra blank lines around the conditional block.
  • file_editor / planning_file_editor (vision disabled): extra blank line inserted where the conditional was removed.
  • gemini read/write/edit/list + glob: blank line before “Your current working directory…” footer removed.
  • browser_use tools + terminal: trailing whitespace/newline differences only.

If you want me to normalize whitespace to verify semantic equivalence, I can do that too.

Co-authored-by: openhands <openhands@all-hands.dev>
Copy link
Copy Markdown
Collaborator

enyst commented Mar 8, 2026

Re-ran the main vs PR tool-description comparison after fixes.

Results:

  • ✅ All checked tool descriptions now match exactly between main and the PR.
  • Updated artifacts in .pr/:
    • .pr/tool-description-compare-results.md
    • .pr/tool-description-diff.md

Commands executed (see .pr/tool-description-compare-results.md for full detail):

  • .pr/tool_description_snapshot.py on PR + main worktree
  • .pr/compare_tool_descriptions.py

@enyst enyst force-pushed the feat/tools-j2-descriptions branch from b52b6da to 7e66c20 Compare March 8, 2026 06:48
Copy link
Copy Markdown
Collaborator

@enyst enyst left a comment

Choose a reason for hiding this comment

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

Thank you!

@enyst enyst enabled auto-merge (squash) March 9, 2026 09:46
@enyst enyst disabled auto-merge March 9, 2026 09:46
@enyst
Copy link
Copy Markdown
Collaborator

enyst commented Mar 9, 2026

@OpenHands remove the entire .pr/ directory, it was temporary just for online testing of the PR. Push to branch; note that it's from a fork so make sure to set the remote properly.

@openhands-ai
Copy link
Copy Markdown

openhands-ai bot commented Mar 9, 2026

I'm on it! enyst can track my progress at all-hands.dev

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai
Copy link
Copy Markdown

openhands-ai bot commented Mar 9, 2026

Final summary:

  • Removed the entire .pr/ directory from the PR branch.
  • Kept the change concise: the diff only contains deletion of the temporary .pr artifacts:
    • .pr/compare_tool_descriptions.py
    • .pr/tool-description-compare-results.md
    • .pr/tool-description-diff.md
    • .pr/tool_description_snapshot.py
  • Used the fork remote for the PR branch, as requested.
  • Committed the change as 9974d3005f78fe3905b5ecf54598ad607661258d with message:
    chore: remove temporary .pr artifacts
  • Pushed the commit to nikhilk7153/software-agent-sdk:feat/tools-j2-descriptions.
  • Left no PR comment, per instruction.

The request has been fully addressed, and there are no extraneous code changes beyond removing the temporary .pr files.

@all-hands-bot
Copy link
Copy Markdown
Collaborator

[Automatic Post]: It has been a while since there was any activity on this PR. @nikhilk7153, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize tool description implementation patterns

4 participants