The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(state): keep tool and oneshot as their own created_source
kshitijk4poorbaedb765780b
diff --git a/gateway/session_policy.py b/gateway/session_policy.pyindex 2d5b413b23f..bc83fe4d910 100644--- a/gateway/session_policy.py+++ b/gateway/session_policy.py@@ -85,12 +85,13 @@ STORED_AS_LOCAL = frozenset(SURFACES) - _KEEP_STORED_LABELdef created_surface(label):"""``created_source`` for a policy or live label.- ``local`` and ``unknown`` are not surfaces. A policy label maps through- ``SURFACES`` (``gui`` is ``desktop``). Any other label is kept as itself.+ ``local`` and ``unknown`` are not surfaces. A label stored as ``local`` maps+ through ``SURFACES`` (``gui`` is ``desktop``). Any other label, including+ ``tool`` and ``oneshot``, is kept as itself: created_source is provenance."""if label in (None, '', 'local', 'unknown'):return None- mapped = SURFACES.get(label, label)+ mapped = SURFACES[label] if label in STORED_AS_LOCAL else labelif mapped in ('', 'local', 'unknown'):return Nonereturn mappeddiff --git a/tests/gateway/test_resume_latest_local_cli.py b/tests/gateway/test_resume_latest_local_cli.pyindex 0336e441e33..3abae21a4c1 100644--- a/tests/gateway/test_resume_latest_local_cli.py+++ b/tests/gateway/test_resume_latest_local_cli.py@@ -235,6 +235,22 @@ def _listed(db, source, capsys):return capsys.readouterr().out+async def test_oneshot_keeps_its_own_created_source_and_stays_out_of_cli(tmp_path, monkeypatch, capsys):+ """created_source is provenance: a oneshot run is stamped oneshot, not the cli it runs as."""+ store, authority, owner = _owner(tmp_path / 'home', monkeypatch)+ try:+ created = await _call(owner, 'session.create', request_id='z', source='oneshot',+ cwd=str(tmp_path), toolsets=[], model='m')+ sid = created['session_id']+ assert authority.db.get_session(sid)['created_source'] == 'oneshot'+ assert sid not in _listed(authority.db, 'cli', capsys)+ assert sid in _listed(authority.db, 'oneshot', capsys)+ finally:+ await owner.close()+ store.close_all_db_handles()++@pytest.mark.asyncio@pytest.mark.parametrize(('surface', 'labels'), [('gui', ('gui', 'desktop')), ('acp', ('acp',))])async def test_gui_and_acp_list_under_the_policy_label_and_the_agent_surface(