Skip to content

feat: add ask_user tool with host-side LLM interception#1

Open
yash-scaleai wants to merge 1 commit intoscaleapi:scale-customizationsfrom
yash-scaleai:yash/ask-user-host-interception
Open

feat: add ask_user tool with host-side LLM interception#1
yash-scaleai wants to merge 1 commit intoscaleapi:scale-customizationsfrom
yash-scaleai:yash/ask-user-host-interception

Conversation

@yash-scaleai
Copy link

Summary

Adds an ask_user tool that allows agents to request clarification on underspecified tasks. The tool simulates user responses using an LLM based on the complete task definition.

Key changes:

  • Add ask_user tool in tools/ask_user/
  • Add TaskDefinitionInjectionHook to inject task definitions into containers
  • Auto-detect task_definitions.json in run_batch.py
  • Critical fix: Intercept ask_user commands on HOST side in agents.py

Why host-side interception?

The original implementation (Bryan's PR #17144) runs the LLM call inside the Modal container. However, Modal containers cannot reach internal API endpoints like litellm.ml-serving-internal.scale.com.

This PR intercepts ask_user commands in agents.py before they are sent to the container, makes the LLM call on the host (where the agent's own LLM calls are made), and returns the response directly.

Flow:

1. Agent outputs: ask_user "what's the cert validation behavior?"
2. Host intercepts command in handle_action()
3. Host makes LLM call (can reach internal API)
4. Response returned directly to agent
5. Container's ask_user binary never runs

Based on Bryan's PR #17144 with architectural modification for internal API compatibility.

Test plan

  • Single task test with scripts/test_ask_user_single.py
  • Verified ask_user interception in logs
  • Verified response in trajectory file

🤖 Generated with Claude Code

Adds an ask_user tool that allows agents to request clarification on
underspecified tasks. The tool simulates user responses using an LLM
based on the complete task definition.

Key changes:
- Add ask_user tool in tools/ask_user/
- Add TaskDefinitionInjectionHook to inject task definitions into containers
- Auto-detect task_definitions.json in run_batch.py
- **Critical fix**: Intercept ask_user commands on HOST side in agents.py

The host-side interception is necessary because Modal containers cannot
reach internal API endpoints (e.g., litellm.ml-serving-internal.scale.com).
By handling the LLM call on the host (where the agent's own LLM calls are
made), we avoid timeout issues while maintaining the same functionality.

Based on Bryan's PR #17144 with architectural modification for internal
API compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedopenai@​2.16.0100100100100100

View full report

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.

1 participant