Skip to content

docs(agent): note sandboxed session access#229

Open
skalidindi wants to merge 2 commits intomodem-dev:mainfrom
skalidindi:docs/hunk-session-sandbox-note
Open

docs(agent): note sandboxed session access#229
skalidindi wants to merge 2 commits intomodem-dev:mainfrom
skalidindi:docs/hunk-session-sandbox-note

Conversation

@skalidindi
Copy link
Copy Markdown

@skalidindi skalidindi commented May 7, 2026

Adds a short troubleshooting note for agent workflows where hunk session * cannot reach the local loopback daemon from inside a sandbox.

I hit this specifically with Codex sandbox mode: hunk session list reported no active sessions even though a Hunk TUI was running and the daemon's /session-api endpoint showed a
registered session. This can make the normal "No active Hunk sessions" guidance misleading.

The docs now suggest probing /session-api directly and rerunning session commands with the agent's local-network or sandbox-escalation mechanism when the daemon does have registered
sessions.

I’d avoid mentioning Claude unless someone confirms it has the same behavior.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR adds a short troubleshooting section to both docs/agent-workflows.md and skills/hunk-review/SKILL.md explaining that some agent sandboxes block loopback access, and providing a curl probe against the session-API endpoint as a diagnostic step.

  • Both files add the same curl diagnostic pointing at http://127.0.0.1:47657/session-api with {"action":"list"}, instructing readers to use the agent's sandbox-escalation mechanism when the direct call succeeds but hunk session * does not.
  • The SKILL.md change places the guidance as the first section under ## Commands, before the existing ## Common errors section which still directs agents to ask users to open Hunk without referencing the new sandbox check.

Confidence Score: 4/5

Documentation-only change; no production code paths are touched and the prose is accurate for default configurations.

The curl probe hardcodes port 47657, which is the default but overrideable via HUNK_MCP_PORT. Users with a custom port will get a silent failure from the probe and draw the wrong conclusion. The Common Errors section in SKILL.md also still sends agents straight to 'ask the user to open Hunk' without first trying the sandbox diagnostic. Both gaps are in documentation, not runtime logic, so they carry low risk, but they reduce the reliability of the troubleshooting guidance the PR is specifically trying to add.

skills/hunk-review/SKILL.md — the Common Errors section's 'No active Hunk sessions' entry should cross-reference the new sandbox guidance.

Important Files Changed

Filename Overview
docs/agent-workflows.md Adds sandbox troubleshooting paragraph under 'How live session control works'; curl probe hardcodes port 47657 without noting the HUNK_MCP_PORT override.
skills/hunk-review/SKILL.md Adds 'Sandboxed agents' section under Commands with the same curl probe; hardcoded port and missing cross-reference from the 'No active Hunk sessions' common error entry.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent runs hunk session list] --> B{Sessions returned?}
    B -- Yes --> C[Proceed normally]
    B -- No --> D[Hunk TUI visibly running?]
    D -- No --> E[Ask user to open Hunk]
    D -- Yes --> F["Probe daemon directly:\ncurl POST /session-api {action:list}"]
    F --> G{Probe returns sessions?}
    G -- No --> H[Daemon unreachable / not running\nAsk user to restart Hunk]
    G -- Yes --> I[Sandbox is blocking loopback\nRerun hunk session * with\nsandbox-escalation mechanism]
Loading

Comments Outside Diff (1)

  1. skills/hunk-review/SKILL.md, line 166 (link)

    P2 The "No active Hunk sessions" common-error entry tells the agent to ask the user to open Hunk, but never points back to the new sandboxed-agents section. An agent following this error handler will skip the sandbox diagnostic and give incorrect advice when the real cause is a blocked loopback connection.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: skills/hunk-review/SKILL.md
    Line: 166
    
    Comment:
    The "No active Hunk sessions" common-error entry tells the agent to ask the user to open Hunk, but never points back to the new sandboxed-agents section. An agent following this error handler will skip the sandbox diagnostic and give incorrect advice when the real cause is a blocked loopback connection.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
skills/hunk-review/SKILL.md:50-56
The curl probe hardcodes port `47657`, but the daemon port is configurable via `HUNK_MCP_PORT`. A user who has set that env var will get a silent failure from the probe and may incorrectly conclude the daemon is unreachable. A short note here keeps the example accurate for the common case while flagging the override.

```suggestion
A useful probe is (port defaults to `47657`; use `$HUNK_MCP_PORT` if you have overridden it):

```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
  -H 'content-type: application/json' \
  --data '{"action":"list"}'
```
```

### Issue 2 of 3
docs/agent-workflows.md:34-41
Same hardcoded port concern as in the SKILL file — if `HUNK_MCP_PORT` is set, the probe will silently fail and lead users down the wrong troubleshooting path.

```suggestion
```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
  -H 'content-type: application/json' \
  --data '{"action":"list"}'
```

> **Note:** the default port is `47657`. If you have set `HUNK_MCP_PORT`, substitute that value in the URL above.

If that direct API call shows sessions, rerun the same `hunk session ...` command with the
agent's local-network or sandbox-escalation mechanism instead of restarting Hunk.
```

### Issue 3 of 3
skills/hunk-review/SKILL.md:166
The "No active Hunk sessions" common-error entry tells the agent to ask the user to open Hunk, but never points back to the new sandboxed-agents section. An agent following this error handler will skip the sandbox diagnostic and give incorrect advice when the real cause is a blocked loopback connection.

```suggestion
- **"No active Hunk sessions"** -- if the user can see Hunk running, first check sandbox loopback access (see [Sandboxed agents](#sandboxed-agents) above); otherwise ask the user to open Hunk in their terminal.
```

Reviews (1): Last reviewed commit: "docs(agent): note sandboxed session acce..." | Re-trigger Greptile

Comment thread skills/hunk-review/SKILL.md Outdated
Comment on lines +50 to +56
A useful probe is:

```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
-H 'content-type: application/json' \
--data '{"action":"list"}'
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The curl probe hardcodes port 47657, but the daemon port is configurable via HUNK_MCP_PORT. A user who has set that env var will get a silent failure from the probe and may incorrectly conclude the daemon is unreachable. A short note here keeps the example accurate for the common case while flagging the override.

Suggested change
A useful probe is:
```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
-H 'content-type: application/json' \
--data '{"action":"list"}'
```
A useful probe is (port defaults to `47657`; use `$HUNK_MCP_PORT` if you have overridden it):
```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
-H 'content-type: application/json' \
--data '{"action":"list"}'

<details><summary>Prompt To Fix With AI</summary>

`````markdown
This is a comment left during a code review.
Path: skills/hunk-review/SKILL.md
Line: 50-56

Comment:
The curl probe hardcodes port `47657`, but the daemon port is configurable via `HUNK_MCP_PORT`. A user who has set that env var will get a silent failure from the probe and may incorrectly conclude the daemon is unreachable. A short note here keeps the example accurate for the common case while flagging the override.

```suggestion
A useful probe is (port defaults to `47657`; use `$HUNK_MCP_PORT` if you have overridden it):

```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
  -H 'content-type: application/json' \
  --data '{"action":"list"}'

How can I resolve this? If you propose a fix, please make it concise.

Comment thread docs/agent-workflows.md
Comment on lines +34 to +41
```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
-H 'content-type: application/json' \
--data '{"action":"list"}'
```

If that direct API call shows sessions, rerun the same `hunk session ...` command with the
agent's local-network or sandbox-escalation mechanism instead of restarting Hunk.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Same hardcoded port concern as in the SKILL file — if HUNK_MCP_PORT is set, the probe will silently fail and lead users down the wrong troubleshooting path.

Suggested change
```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
-H 'content-type: application/json' \
--data '{"action":"list"}'
```
If that direct API call shows sessions, rerun the same `hunk session ...` command with the
agent's local-network or sandbox-escalation mechanism instead of restarting Hunk.
```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
-H 'content-type: application/json' \
--data '{"action":"list"}'

Note: the default port is 47657. If you have set HUNK_MCP_PORT, substitute that value in the URL above.

If that direct API call shows sessions, rerun the same hunk session ... command with the
agent's local-network or sandbox-escalation mechanism instead of restarting Hunk.


<details><summary>Prompt To Fix With AI</summary>

`````markdown
This is a comment left during a code review.
Path: docs/agent-workflows.md
Line: 34-41

Comment:
Same hardcoded port concern as in the SKILL file — if `HUNK_MCP_PORT` is set, the probe will silently fail and lead users down the wrong troubleshooting path.

```suggestion
```bash
curl -s -X POST http://127.0.0.1:47657/session-api \
  -H 'content-type: application/json' \
  --data '{"action":"list"}'

Note: the default port is 47657. If you have set HUNK_MCP_PORT, substitute that value in the URL above.

If that direct API call shows sessions, rerun the same hunk session ... command with the
agent's local-network or sandbox-escalation mechanism instead of restarting Hunk.


How can I resolve this? If you propose a fix, please make it concise.

@benvinegar
Copy link
Copy Markdown
Member

I feel like I just want to abandon the HTTP server and move to a socket instead. Would that solve the sandbox issue?

@skalidindi
Copy link
Copy Markdown
Author

skalidindi commented May 8, 2026

Yes, I think that is the cleaner direction and should avoid the specific Codex failure mode because the agent would no longer need loopback TCP access. Note that the Unix-domain socket would also still need to live somewhere visible to both processes like the existing runtime dir and have sensible per-user permissions for the agent to see it in sandbox mode.

If you want to replace the transport soon, I’m happy to either close this or keep it as a temporary solution until then. Fine either way.

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.

2 participants