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
3 changes: 3 additions & 0 deletions .autoskillit/test-filter-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ tests/fixtures/codex/*.jsonl:
tests/fixtures/codex/discovery_prompt_input_*.json:
- execution/

tests/fixtures/codex/discovery_prompt_input_*.md:
- execution/

tests/fixtures/codex_hook_protocol/**/*.json:
- hooks/

Expand Down
2 changes: 1 addition & 1 deletion src/autoskillit/cli/fleet/_fleet_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from cyclopts import Parameter

from autoskillit.cli.session._session_launch import render_skill_unavailability
from autoskillit.cli.session._session_onboarding import render_skill_unavailability
from autoskillit.core import get_logger, is_feature_enabled

if TYPE_CHECKING:
Expand Down
37 changes: 24 additions & 13 deletions src/autoskillit/cli/fleet/_fleet_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from autoskillit.core import (
CODEX_AUTO_COMPACTION_BLOCKED_MESSAGE,
FLEET_SESSION_REQUIRED_ENV,
MANAGED_JOIN_PARENT_ID_ENV_VAR,
CodingAgentBackend,
FleetSessionEnv,
FreshLaunch,
Expand Down Expand Up @@ -65,20 +66,25 @@ def _fleet_session_launcher(
managed_join_parent_id: str | None = None,
) -> Iterator[Callable[[InteractiveLaunch, dict[str, str]], Any]]:
"""Keep one leased wrapper home through a fleet session's retry loop."""
from autoskillit.cli.session._session_launch import _run_interactive_session
from autoskillit.cli.session._session_launch import (
InteractiveLaunchValidationError,
_run_interactive_session,
render_launch_validation_errors,
)

parent_env = (
{MANAGED_JOIN_PARENT_ID_ENV_VAR: managed_join_parent_id}
if managed_join_parent_id is not None
else {}
)

def raw_launch(
launch: InteractiveLaunch,
extra_env: dict[str, str],
) -> Any:
launch_env = dict(extra_env)
if managed_join_parent_id is not None:
from autoskillit.core import MANAGED_JOIN_PARENT_ID_ENV_VAR

launch_env[MANAGED_JOIN_PARENT_ID_ENV_VAR] = managed_join_parent_id
return _run_interactive_session(
launch=launch,
extra_env=launch_env,
extra_env={**extra_env, **parent_env},
project_dir=project_dir,
required_env=FLEET_SESSION_REQUIRED_ENV,
backend=backend,
Expand All @@ -96,7 +102,6 @@ def raw_launch(
from autoskillit.cli.session._session_startup_trace import StartupTrace
from autoskillit.core import (
LAUNCH_ID_ENV_VAR,
MANAGED_JOIN_PARENT_ID_ENV_VAR,
PluginLoadMode,
plugin_launch_binding_scope,
resolve_temp_dir,
Expand Down Expand Up @@ -137,6 +142,7 @@ def raw_launch(
launch_load_mode if launch_load_mode.consumes_artifact else PluginLoadMode.PROJECTED_HOME
)
launch_id = uuid.uuid4().hex[:16]
launch_rejected = False
with plugin_launch_binding_scope(
authority=authority,
backend=backend,
Expand Down Expand Up @@ -172,9 +178,7 @@ def managed_launch(
) -> Any:
nonlocal attempt
attempt += 1
launch_env = {**extra_env, LAUNCH_ID_ENV_VAR: launch_id}
if managed_join_parent_id is not None:
launch_env[MANAGED_JOIN_PARENT_ID_ENV_VAR] = managed_join_parent_id
launch_env = {**extra_env, LAUNCH_ID_ENV_VAR: launch_id, **parent_env}
return _run_interactive_session(
launch=launch,
extra_env=launch_env,
Expand All @@ -195,10 +199,17 @@ def managed_launch(

try:
yield managed_launch
except InteractiveLaunchValidationError as exc:
render_launch_validation_errors(exc.errors)
trace.close(status="failed")
launch_rejected = True
except BaseException:
trace.close(status="failed")
raise
trace.close(status="success")
else:
trace.close(status="success")
if launch_rejected:
raise SystemExit(1)


def _refresh_campaign_after_resume(
Expand Down Expand Up @@ -329,7 +340,7 @@ def _launch_fleet_session(
from autoskillit.cli.session._session_backend import (
resolve_global_backend,
)
from autoskillit.cli.session._session_launch import render_skill_unavailability
from autoskillit.cli.session._session_onboarding import render_skill_unavailability
from autoskillit.config import load_config
from autoskillit.workspace import (
compile_session_skill_catalog,
Expand Down
55 changes: 30 additions & 25 deletions src/autoskillit/cli/session/_session_cook.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
from typing import TYPE_CHECKING, assert_never

from autoskillit.cli.session._session_launch import (
InteractiveLaunchValidationError,
_exit_launch_preparation_error,
append_skill_unavailability,
prepare_interactive_launch,
render_launch_validation_errors,
)
from autoskillit.cli.session._session_onboarding import (
append_skill_unavailability,
render_skill_catalog_exclusions,
render_skill_contract_composition_failure,
render_skill_unavailability,
validate_cook_skill_visibility,
)
from autoskillit.core import (
PluginLaunchBinding,
Expand Down Expand Up @@ -466,9 +471,7 @@ def _execute_cook_attempt(
assert_resume_purity(spec=spec, launch=launch)
validation = backend.validate_interactive_invocation(spec)
if validation.errors:
raise RuntimeError(
"Interactive invocation validation failed: " + "; ".join(validation.errors)
)
raise InteractiveLaunchValidationError(validation.errors)
with backend.session_attempt_context(
session_home=managed_home.generated_home,
project_dir=project_dir,
Expand Down Expand Up @@ -605,7 +608,6 @@ def cook(
compile_session_skill_catalog,
resolve_ephemeral_root,
resolve_persistent_session_roots,
validate_skill_tier_roles,
)

config = load_config()
Expand All @@ -614,11 +616,7 @@ def cook(
project_dir = resolve_project_dir()
skill_resolver = DefaultSkillResolver()
skill_visibility = config.skill_visibility_spec()
try:
validate_skill_tier_roles(skill_visibility, skill_resolver, project_dir)
except SkillContractError as exc:
render_skill_contract_composition_failure(exc)
raise SystemExit(1) from exc
validate_cook_skill_visibility(skill_visibility, skill_resolver, project_dir)
backend = _resolve_cook_backend(config, backend)
cook_system_prompt = (
_COOK_PRE_REVEALED_KITCHEN_PROMPT
Expand Down Expand Up @@ -718,6 +716,7 @@ def cook(
projection_load_mode = (
load_mode if load_mode.consumes_artifact else PluginLoadMode.PROJECTED_HOME
)
launch_rejected = False
with (
plugin_launch_binding_scope(
authority=artifact_authority,
Expand Down Expand Up @@ -763,21 +762,27 @@ def cook(
cook_env_extras = _build_cook_attempt_env(
launch_id, profile, config, managed_join_context
)
_run_managed_cook(
backend=backend,
project_dir=project_dir,
launch=launch,
launch_id=launch_id,
config=config,
cook_env_extras=cook_env_extras,
managed_home=managed_home,
projection_binding=projection_binding,
load_mode=load_mode,
trace=trace,
trace_enabled=trace_enabled,
force_inactive_agent_teams=force_inactive_agent_teams,
showed_onboarding=showed_onboarding,
)
try:
_run_managed_cook(
backend=backend,
project_dir=project_dir,
launch=launch,
launch_id=launch_id,
config=config,
cook_env_extras=cook_env_extras,
managed_home=managed_home,
projection_binding=projection_binding,
load_mode=load_mode,
trace=trace,
trace_enabled=trace_enabled,
force_inactive_agent_teams=force_inactive_agent_teams,
showed_onboarding=showed_onboarding,
)
except InteractiveLaunchValidationError as exc:
render_launch_validation_errors(exc.errors)
launch_rejected = True
if launch_rejected:
raise SystemExit(1)
finally:
if claimed_launch_id is not None:
core.release_session_claim(project_dir, claimed_launch_id)
Expand Down
Loading
Loading