Files
dev/sdk/python/tests/test_app_server_goal_operations.py
T
zeekayandHanzo Dev 6cbbea2d03 merge: just-every/code v0.6.169 (e4fe007150) — keep Hanzo identity
Our history is just-every's with author emails rewritten, so the graphs are
disjoint and git finds no merge base. Supplied one by hand: d1f1f51a41, the
just-every commit matching our Oct-2025 fork point (22 files apart). 9618
upstream commits, 7004 files, +1.81M/-159k, 37 conflicts.

Resolution:
- Upstream code where our side was the Oct-2025 prototype of a feature they
  have since reimplemented 3-5x larger (agent_runs, browser_sessions,
  history_cell/{agent,browser}, the vt100 harness and its snapshots).
- Upstream's config.rs module split (builder/defaults/sources/validation)
  kept; zen5-coder and the provider-follows-model rule re-applied on top.
- Ours where the file IS the identity: README, package.json, postinstall,
  release notes pipeline, integration-zed.
- Hybrid where upstream improved a file we had branded: updates.rs (their
  release-repo migration, our hanzoai/dev), release.yml (their fail-fast npm
  auth check, our package name), chatwidget.rs (their turn handling, our
  HANZO_USER_KEY hint), exec human output (their 237 lines, our banner).

Superseded and dropped deliberately: our resume_command_name() coder-alias
hack — upstream's derive_resume_command_name() reads the invocation basename
generically, which yields "dev" for us.

LLM.md now records the real topology and the sync point; AGENTS.md and
CLAUDE.md are symlinks to it again. Single parent on purpose: adopting
jecode/main as a second parent would re-import 13,742 commits carrying the
upstream author emails a prior rewrite deliberately removed.

Version 0.2.188 -> 0.2.189.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-05 23:09:12 -07:00

91 lines
3.4 KiB
Python

from app_server_harness import (
AppServerHarness,
ev_assistant_message,
ev_completed,
ev_function_call,
ev_response_created,
sse,
)
from app_server_helpers import agent_message_texts
from openai_codex import Codex
from openai_codex._goal import _GoalNotificationStream
from openai_codex._run import _collect_turn_result
from openai_codex.generated.notification_registry import notification_turn_id
from openai_codex.generated.v2_all import TurnStatus
def test_private_goal_operation_coalesces_runtime_continuations(tmp_path) -> None:
"""The private engine should expose automatic continuations as one turn."""
with AppServerHarness(tmp_path) as harness:
harness.responses.enqueue_assistant_message(
"Initial pass complete.",
response_id="goal-initial",
)
harness.responses.enqueue_sse(
sse(
[
ev_response_created("goal-complete-tool"),
ev_function_call(
"call-goal-complete",
"update_goal",
'{"status":"complete"}',
),
ev_completed("goal-complete-tool"),
]
)
)
harness.responses.enqueue_sse(
sse(
[
ev_response_created("goal-final"),
ev_assistant_message("msg-goal-final", "Goal complete."),
ev_completed("goal-final"),
]
)
)
with Codex(config=harness.app_server_config()) as codex:
thread = codex.thread_start()
state, turn_id = codex._client.start_goal_operation( # noqa: SLF001
thread.id,
"Improve benchmark coverage",
)
stream = _GoalNotificationStream(
state,
state.next_notification,
lambda: codex._client.unregister_goal_operation(state), # noqa: SLF001
lambda: codex._client.cancel_goal_operation(state), # noqa: SLF001
)
events = list(stream)
result = _collect_turn_result(iter(events), turn_id=turn_id)
routes = codex._client._router._goal_operations.copy() # noqa: SLF001
requests = harness.responses.wait_for_requests(3)
lifecycle = [event.method for event in events if event.method.startswith("turn/")]
routed_ids = [
routed_id
for event in events
if (routed_id := notification_turn_id(event.payload)) is not None
]
assert {
"lifecycle": lifecycle,
"routed_ids": routed_ids,
"result": (result.id, result.status, result.final_response),
"messages": agent_message_texts(events),
"request_count": len(requests),
"objective_reached_model": (
"<objective>\nImprove benchmark coverage\n</objective>"
in "\n".join(requests[0].message_input_texts("user"))
),
"routes_after_completion": routes,
} == {
"lifecycle": ["turn/started", "turn/completed"],
"routed_ids": [turn_id] * len(routed_ids),
"result": (turn_id, TurnStatus.completed, "Goal complete."),
"messages": ["Initial pass complete.", "Goal complete."],
"request_count": 3,
"objective_reached_model": True,
"routes_after_completion": {},
}