refactor: clean CLI taxonomy — canonical subcommands, merged memory.update, no aliases
- calendar: split write → create/read/update/delete/share - contacts: rename lookup → read - memory: merge write+forget → update (unified action field in operations) - Remove all alias/normalization logic from adapter and handlers - Update tool_postprocessor ui_hints builders to canonical keys - Remove frontend legacy TOOL_CALL_START/ARGS/END events and ToolCallItem - Update SKILL.md files and protocol docs - Update tests and settings screens
This commit is contained in:
@@ -22,6 +22,11 @@ from core.agentscope.utils import (
|
||||
finalize_json_response,
|
||||
patch_agentscope_json_repair_compat,
|
||||
)
|
||||
from core.auth.credential_issuer import create_credential_issuer
|
||||
from core.auth.tool_credential_context import (
|
||||
set_tool_credential,
|
||||
reset_tool_credential,
|
||||
)
|
||||
from core.config.settings import config
|
||||
from core.db.session import AsyncSessionLocal
|
||||
from models.llm import Llm
|
||||
@@ -37,7 +42,7 @@ from schemas.agent.runtime_models import (
|
||||
RouterAgentOutput,
|
||||
WorkerAgentOutputLite,
|
||||
)
|
||||
from schemas.agent.skill_config import SkillName
|
||||
from schemas.agent.skill_config import ProjectCliCommand, SkillName
|
||||
from schemas.agent.system_agent import (
|
||||
AgentType,
|
||||
SystemAgentLLMConfig,
|
||||
@@ -107,7 +112,8 @@ class AgentScopeRunner:
|
||||
agent_type=AgentType.WORKER,
|
||||
)
|
||||
worker_toolkit = self._build_toolkit(
|
||||
enabled_skills=runtime_config.enabled_skills
|
||||
enabled_skills=runtime_config.enabled_skills,
|
||||
allowed_commands=runtime_config.allowed_commands,
|
||||
)
|
||||
|
||||
router_output = await self._execute_router_step(
|
||||
@@ -174,10 +180,13 @@ class AgentScopeRunner:
|
||||
self,
|
||||
*,
|
||||
enabled_skills: list[SkillName],
|
||||
allowed_commands: list[ProjectCliCommand],
|
||||
) -> Any:
|
||||
enabled_skill_names = {str(skill.value) for skill in enabled_skills}
|
||||
allowed_command_names = {str(command.value) for command in allowed_commands}
|
||||
return build_toolkit(
|
||||
enabled_skill_names=enabled_skill_names if enabled_skill_names else None
|
||||
enabled_skill_names=enabled_skill_names if enabled_skill_names else None,
|
||||
allowed_commands=allowed_command_names if allowed_command_names else None,
|
||||
)
|
||||
|
||||
async def _load_stage_config(
|
||||
@@ -388,56 +397,66 @@ class AgentScopeRunner:
|
||||
work_memory: WorkProfileContent | None,
|
||||
requires_tool_evidence: bool = False,
|
||||
) -> StageExecutionResult:
|
||||
tracking_model = self._build_model(stage_config=stage_config)
|
||||
emitter = PipelineStageEmitter(
|
||||
pipeline=pipeline,
|
||||
session_id=run_input.thread_id,
|
||||
run_id=run_input.run_id,
|
||||
stage=stage_config.agent_type.value,
|
||||
runtime_mode=runtime_mode.value,
|
||||
emit_text_events=True,
|
||||
emit_tool_events=True,
|
||||
issuer = create_credential_issuer()
|
||||
credential = issuer.issue(
|
||||
owner_id=str(user_context.id),
|
||||
mode=runtime_mode.value,
|
||||
)
|
||||
agent = self._build_agent(
|
||||
agent_name=stage_config.agent_type.value,
|
||||
system_prompt=build_system_prompt(
|
||||
agent_type=stage_config.agent_type,
|
||||
llm_config=stage_config.llm_config,
|
||||
user_context=user_context,
|
||||
now_utc=datetime.now(timezone.utc),
|
||||
runtime_client_time=runtime_client_time,
|
||||
extra_context=stage_config.extra_context,
|
||||
work_memory=work_memory,
|
||||
),
|
||||
toolkit=toolkit,
|
||||
model=tracking_model,
|
||||
emitter=emitter,
|
||||
force_tool_on_first_reasoning=requires_tool_evidence,
|
||||
)
|
||||
async with self._active_agent_lock:
|
||||
self._active_agent = agent
|
||||
credential_token = set_tool_credential(credential)
|
||||
|
||||
try:
|
||||
response_msg = await agent.reply_json(
|
||||
input_messages, output_model=worker_output_model
|
||||
tracking_model = self._build_model(stage_config=stage_config)
|
||||
emitter = PipelineStageEmitter(
|
||||
pipeline=pipeline,
|
||||
session_id=run_input.thread_id,
|
||||
run_id=run_input.run_id,
|
||||
stage=stage_config.agent_type.value,
|
||||
runtime_mode=runtime_mode.value,
|
||||
emit_text_events=True,
|
||||
emit_tool_events=True,
|
||||
)
|
||||
agent = self._build_agent(
|
||||
agent_name=stage_config.agent_type.value,
|
||||
system_prompt=build_system_prompt(
|
||||
agent_type=stage_config.agent_type,
|
||||
llm_config=stage_config.llm_config,
|
||||
user_context=user_context,
|
||||
now_utc=datetime.now(timezone.utc),
|
||||
runtime_client_time=runtime_client_time,
|
||||
extra_context=stage_config.extra_context,
|
||||
work_memory=work_memory,
|
||||
),
|
||||
toolkit=toolkit,
|
||||
model=tracking_model,
|
||||
emitter=emitter,
|
||||
force_tool_on_first_reasoning=requires_tool_evidence,
|
||||
)
|
||||
async with self._active_agent_lock:
|
||||
self._active_agent = agent
|
||||
try:
|
||||
response_msg = await agent.reply_json(
|
||||
input_messages, output_model=worker_output_model
|
||||
)
|
||||
finally:
|
||||
async with self._active_agent_lock:
|
||||
if self._active_agent is agent:
|
||||
self._active_agent = None
|
||||
worker_payload = worker_output_model.model_validate(response_msg.metadata or {})
|
||||
response_metadata = self._llm_pricing_service.build_usage_metadata(
|
||||
model=stage_config.model_code,
|
||||
usage_summary=tracking_model.usage_summary(),
|
||||
)
|
||||
await emitter.emit_final_text_end(
|
||||
worker_output=worker_payload.model_dump(mode="json", exclude_none=True),
|
||||
response_metadata=response_metadata,
|
||||
)
|
||||
return StageExecutionResult(
|
||||
message=response_msg,
|
||||
payload=worker_payload.model_dump(mode="json", exclude_none=True),
|
||||
response_metadata=response_metadata,
|
||||
)
|
||||
finally:
|
||||
async with self._active_agent_lock:
|
||||
if self._active_agent is agent:
|
||||
self._active_agent = None
|
||||
worker_payload = worker_output_model.model_validate(response_msg.metadata or {})
|
||||
response_metadata = self._llm_pricing_service.build_usage_metadata(
|
||||
model=stage_config.model_code,
|
||||
usage_summary=tracking_model.usage_summary(),
|
||||
)
|
||||
await emitter.emit_final_text_end(
|
||||
worker_output=worker_payload.model_dump(mode="json", exclude_none=True),
|
||||
response_metadata=response_metadata,
|
||||
)
|
||||
return StageExecutionResult(
|
||||
message=response_msg,
|
||||
payload=worker_payload.model_dump(mode="json", exclude_none=True),
|
||||
response_metadata=response_metadata,
|
||||
)
|
||||
reset_tool_credential(credential_token)
|
||||
|
||||
def _build_worker_input_messages(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user