Skip to content

[Bug]: Example 51 (agent hooks) asks for a report on "this repository" from an empty temp directory #6659

Closed

Description

@enyst

I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

The verify-sdk feature map (#5750) found this bug while running the SDK's examples with a real model. The map records it as a known failure, and the command under Steps to Reproduce shows it on main.

Is there an existing issue for the same bug?

  • I have searched existing issues and this is not a duplicate.

Bug Description

Demo 2 of examples/01_standalone_sdk/51_agent_hooks/main.py asks the agent for a REPORT.md "describing this repository", but its workspace is an empty temporary directory. With DeepSeek Flash the model went looking for a repository elsewhere on the machine (it listed /home/user and ran git log in other checkouts), spent the example's 10-iteration cap, and the example raised RuntimeError: Demo conversation ended in error state before reaching a decision. Reproduced twice. Demo 1 passes. This is a bug in the example, not in the SDK.

Expected Behavior

Demo 2 prints Stop lines from agent-hook:quality-reviewer and a REPORT.md preview, then Example Complete!.

Actual Behavior

RuntimeError after 10 iterations, with the agent reading files outside its workspace.

Steps to Reproduce

From a checkout of main (uv sync), with the verify-sdk tools on the path and DEEPSEEK_API_KEY set:

export PATH="$PWD/.agents/skills/verify-sdk/scripts:$PATH"
sdk-map run --file S10 --only S10.agent-hook --with-llm

That runs this recipe from the map:

export SDK_VERIFY_RUN=$(control-sdk new --llm deepseek-flash --field run)
control-sdk exec --model-env --expect-output "Example Complete!" --expect-output "EXAMPLE_COST" -- python examples/01_standalone_sdk/51_agent_hooks/main.py

Acceptance Criteria

  • Demo 2 gives the agent something to describe inside its workspace (or a task that needs no repository).
  • The example completes with a real model.
  • The example-51 bullet in .agents/skills/verify-sdk/references/feature-map/S10-hooks.md passes and its known-failure note is removed.

Installation Method

uv sync in a checkout of main


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Confirmed against examples/01_standalone_sdk/51_agent_hooks/main.py on main: both demos share one empty tempfile.TemporaryDirectory() workspace, while Demo 2 asks the agent to write REPORT.md "describing this repository" and the quality-reviewer hook requires a bullet "describing the repository". The verify-sdk feature map (.agents/skills/verify-sdk/references/feature-map/S10-hooks.md) records this as a known failure reproduced twice (DeepSeek Flash, 2026-11-03): the agent searched outside the workspace (listed /home/user, ran git log in other checkouts), exhausted the 10-iteration cap, and the example raised RuntimeError. Demo 1 passes and the SDK itself is unaffected — this is an example bug, consistent with the report.

Scope (resolved from repository evidence): the issue offered "give the agent something to describe inside its workspace (or a task that needs no repository)". The adjacent examples/01_standalone_sdk/33_hooks/main.py already seeds its temporary workspace with a repository (git init -q plus files), so example 51 follows that precedent and seeds workspace content that Demo 2's task can be completed against. Bounded to this one example plus its README and the feature-map note; priority stays priority:low (demo tooling, demo 1 unaffected, clear workaround, no product impact).

Non-goals: no changes to SDK hook, conversation, or workspace behavior; no changes to other examples; no changes to the example's iteration cap, fail-fast RuntimeError, or hook fall-open semantics; no model-specific handling.

Acceptance Criteria

  • The example seeds its temporary workspace with content the Demo 2 agent can describe (e.g., a git repository with files, as 33_hooks/main.py already does), so the quality-reviewer's REPORT.md requirement is satisfiable from inside the workspace.
  • Running uv run python examples/01_standalone_sdk/51_agent_hooks/main.py with a real model (LLM_API_KEY set, as in the issue's verify-sdk run or the Run Examples Scripts workflow) completes without RuntimeError ... ended in error state; Demo 2 prints at least one [hook] Stop line from agent-hook:quality-reviewer, prints a REPORT.md preview, and the script ends with Example Complete! and an EXAMPLE_COST: line.
  • Demo 1 still behaves as documented: it prints a [hook] PreToolUse DENY -> agent-hook:security-reviewer line for the awk '{print}' /etc/passwd request.
  • The example creates and modifies files only inside its temporary workspace; no paths outside it (e.g., the machine's other repositories or $HOME) are read as part of producing REPORT.md when run in the reproduction environment.
  • uv run pytest tests/examples/test_examples.py --run-examples passes for 51_agent_hooks with no change to _TARGET_DIRECTORIES.
  • .agents/skills/verify-sdk/references/feature-map/S10-hooks.md: the example-51 live bullet (S10.agent-hook, S10.stop-hook, S10.execution-events) passes and the "Known failure" note about Demo 2 is removed.

Activity

  1. added
    bug
    ready-for-dev
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions