Skip to content

Commit 0c3348c

Browse files
authored
Merge pull request #906 from crestalnetwork/ops/auto-2025-11-13
chore: merge ops/auto-2025-11-13 into main
2 parents 33e3dd9 + 8928e5f commit 0c3348c

File tree

13 files changed

+439
-343
lines changed

13 files changed

+439
-343
lines changed

intentkit/core/engine.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@
6767
_agents_updated: dict[str, datetime] = {}
6868

6969

70+
def _extract_text_content(content: object) -> str:
71+
if isinstance(content, list):
72+
texts: list[str] = []
73+
for item in content:
74+
if isinstance(item, dict):
75+
t = item.get("text")
76+
ty = item.get("type")
77+
if t is not None and (ty == "text" or ty is None):
78+
texts.append(t)
79+
elif isinstance(item, str):
80+
texts.append(item)
81+
return "".join(texts)
82+
if isinstance(content, dict):
83+
if content.get("type") == "text" and "text" in content:
84+
return content["text"]
85+
if "text" in content:
86+
return content["text"]
87+
return ""
88+
if isinstance(content, str):
89+
return content
90+
return ""
91+
92+
7093
async def build_agent(
7194
agent: Agent, agent_data: AgentData, custom_skills: list[BaseTool] = []
7295
) -> CompiledStateGraph:
@@ -149,8 +172,8 @@ async def select_model(
149172
if llm_model.info.provider == LLMProvider.OPENAI:
150173
tools.append({"type": "web_search"})
151174
private_tools.append({"type": "web_search"})
152-
if agent.model.startswith("gpt-5-"):
153-
llm_params["reasoning_effort"] = "low"
175+
if llm_model.info.model_name == "gpt-5-mini":
176+
llm_params["reasoning_effort"] = "medium"
154177
if llm_model.info.provider == LLMProvider.XAI:
155178
llm_params["search_parameters"] = {"mode": "auto"}
156179
# TODO: else use a search skill
@@ -431,31 +454,30 @@ async def stream_agent_raw(
431454

432455
# super mode
433456
recursion_limit = 30
434-
if re.search(r"\b@super\b", input_message):
457+
if re.search(r"@super\b", input_message) or user_message.super_mode:
435458
recursion_limit = 300
436459
# Remove @super from the message
437-
input_message = re.sub(r"\b@super\b", "", input_message).strip()
460+
input_message = re.sub(r"@super\b", "", input_message).strip()
438461

439462
# llm native search
440-
search = False
441-
if re.search(r"\b@search\b", input_message) or re.search(
442-
r"\b@web\b", input_message
443-
):
463+
search = user_message.search_mode if user_message.search_mode is not None else False
464+
if re.search(r"@search\b", input_message) or re.search(r"@web\b", input_message):
444465
search = True
445466
if model.supports_search:
446467
input_message = re.sub(
447-
r"\b@search\b",
468+
r"@search\b",
448469
"(You have native search tool, you can use it to get more recent information)",
449470
input_message,
450471
).strip()
451472
input_message = re.sub(
452-
r"\b@web\b",
473+
r"@web\b",
453474
"(You have native search tool, you can use it to get more recent information)",
454475
input_message,
455476
).strip()
456477
else:
457-
input_message = re.sub(r"\b@search\b", "", input_message).strip()
458-
input_message = re.sub(r"\b@web\b", "", input_message).strip()
478+
search = False
479+
input_message = re.sub(r"@search\b", "", input_message).strip()
480+
input_message = re.sub(r"@web\b", "", input_message).strip()
459481

460482
# content to llm
461483
messages = [
@@ -526,16 +548,7 @@ def get_agent() -> Agent:
526548
# tool calls, save for later use, if it is deleted by post_model_hook, will not be used.
527549
cached_tool_step = msg
528550
if hasattr(msg, "content") and msg.content:
529-
content = msg.content
530-
if isinstance(msg.content, list):
531-
# in new version, content item maybe a list
532-
content = msg.content[0]
533-
if isinstance(content, dict):
534-
if "text" in content:
535-
content = content["text"]
536-
else:
537-
content = str(content)
538-
logger.error(f"unexpected content type: {content}")
551+
content = _extract_text_content(msg.content)
539552
# agent message
540553
chat_message_create = ChatMessageCreate(
541554
id=str(XID()),

intentkit/core/prompt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async def explain_prompt(message: str) -> str:
250250
str: The processed message with @skill patterns replaced
251251
"""
252252
# Pattern to match @skill:category:config_name with word boundaries
253-
pattern = r"\b@skill:([^:]+):([^\s]+)\b"
253+
pattern = r"@skill:([^:]+):([^\s]+)\b"
254254

255255
async def replace_skill_pattern(match):
256256
category = match.group(1)

0 commit comments

Comments
 (0)