Skip to content
Merged
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
2 changes: 1 addition & 1 deletion sdk/guides/agent-server/custom-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
## How It Works

1. **Define custom tool** with `register_tool()` at module level
2. **Create Dockerfile** that copies tools and sets `PYTHONPATH`

Check warning on line 18 in sdk/guides/agent-server/custom-tools.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/agent-server/custom-tools.mdx#L18

Did you really mean 'Dockerfile'?
3. **Build custom base image** with your tools
4. **Use `DockerDevWorkspace`** with `base_image` parameter - it builds the agent server on top
5. **Import tool module** in client before creating conversation
Expand Down Expand Up @@ -212,7 +212,7 @@
register_tool("LogDataTool", LogDataTool)
```

### Dockerfile

Check warning on line 215 in sdk/guides/agent-server/custom-tools.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/agent-server/custom-tools.mdx#L215

Did you really mean 'Dockerfile'?

```dockerfile icon="docker"
FROM nikolaik/python-nodejs:python3.12-nodejs22
Expand All @@ -226,7 +226,7 @@
| Issue | Solution |
|-------|----------|
| Tool not found | Ensure `register_tool()` is called at module level, import tool before creating conversation |
| Import errors on server | Check `PYTHONPATH` in Dockerfile, verify all dependencies installed |

Check warning on line 229 in sdk/guides/agent-server/custom-tools.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/agent-server/custom-tools.mdx#L229

Did you really mean 'Dockerfile'?
| Build failures | Verify file paths in `COPY` commands, ensure Python 3.12+ |

<Warning>
Expand All @@ -239,7 +239,7 @@
This example is available on GitHub: [examples/02_remote_agent_server/06_custom_tool/](https://github.com/OpenHands/software-agent-sdk/tree/main/examples/02_remote_agent_server/06_custom_tool)
</Note>

```python icon="python" expandable examples/02_remote_agent_server/06_custom_tool/custom_tool_example.py
```python icon="python" expandable examples/02_remote_agent_server/06_custom_tool/main.py
"""Example: Using custom tools with remote agent server.

This example demonstrates how to use custom tools with a remote agent server
Expand Down
4 changes: 2 additions & 2 deletions sdk/guides/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
This example is available on GitHub: [examples/01_standalone_sdk/33_hooks](https://github.com/OpenHands/software-agent-sdk/blob/main/examples/01_standalone_sdk/33_hooks/)
</Note>

```python icon="python" expandable examples/01_standalone_sdk/33_hooks/33_hooks.py
```python icon="python" expandable examples/01_standalone_sdk/33_hooks/main.py
"""OpenHands Agent SDK — Hooks Example

Demonstrates the OpenHands hooks system.
Expand Down Expand Up @@ -212,7 +212,7 @@
cost = conversation.conversation_stats.get_combined_metrics().accumulated_cost
print(f"\nEXAMPLE_COST: {cost}")
```
<RunExampleCode path_to_script="examples/01_standalone_sdk/33_hooks/33_hooks.py"/>
<RunExampleCode path_to_script="examples/01_standalone_sdk/33_hooks/main.py"/>


### Hook Scripts
Expand All @@ -223,7 +223,7 @@
```bash
#!/bin/bash
# PreToolUse hook: Block dangerous rm -rf commands
# Uses jq for JSON parsing (needed for nested fields like tool_input.command)

Check warning on line 226 in sdk/guides/hooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/hooks.mdx#L226

Did you really mean 'jq'?

input=$(cat)
command=$(echo "$input" | jq -r '.tool_input.command // ""')
Expand All @@ -232,7 +232,7 @@
if [[ "$command" =~ "rm -rf" ]]; then
echo '{"decision": "deny", "reason": "rm -rf commands are blocked for safety"}'
exit 2 # Exit code 2 = block the operation
fi

Check warning on line 235 in sdk/guides/hooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/hooks.mdx#L235

Did you really mean 'fi'?

exit 0 # Exit code 0 = allow the operation
```
Expand All @@ -242,7 +242,7 @@
```bash
#!/bin/bash
# PostToolUse hook: Log all tool usage
# Uses OPENHANDS_TOOL_NAME env var (no jq/python needed!)

Check warning on line 245 in sdk/guides/hooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/hooks.mdx#L245

Did you really mean 'jq'?

# LOG_FILE should be set by the calling script
LOG_FILE="${LOG_FILE:-/tmp/tool_usage.log}"
Expand All @@ -266,10 +266,10 @@
status=$(git status --short 2>/dev/null | head -10)
if [ -n "$status" ]; then
# Escape for JSON
escaped=$(echo "$status" | sed 's/"/\\"/g' | tr '\n' ' ')

Check warning on line 269 in sdk/guides/hooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/hooks.mdx#L269

Did you really mean 'sed'?
echo "{\"additionalContext\": \"Current git status: $escaped\"}"
fi
fi

Check warning on line 272 in sdk/guides/hooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/guides/hooks.mdx#L272

'fi' is repeated!
fi
exit 0
```
Expand Down
Loading