Skip to content

Commit c195ed8

Browse files
committed
Merge branch 'test' into tools-json
2 parents f1f5921 + 2c8cc9d commit c195ed8

49 files changed

Lines changed: 2245 additions & 435 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

agents/matmaster_agent/constant.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
BOHRIUM_COM = f'https://www{URL_PART}.bohrium.com'
5050
BOHRIUM_HOST = f'https://bohrium{URL_PART}.dp.tech'
5151
ICL_SERVICE_URL = '101.126.90.82:8001'
52+
MEMORY_SERVICE_URL = '101.126.90.82:8002'
5253
MATMASTER_TOOLS_SERVER = f'https://matmaster-tools-server{URL_PART}.bohrium.com'
5354
if CURRENT_ENV == 'test':
5455
DFLOW_HOST = 'https://lbg-workflow-mlops.test.dp.tech'

agents/matmaster_agent/core_agents/base_agents/mcp_agent.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
check_user_phonon_balance,
1414
default_after_model_callback,
1515
default_after_tool_callback,
16+
default_before_model_callback,
1617
default_before_tool_callback,
1718
default_cost_func,
1819
filter_function_calls,
@@ -42,6 +43,12 @@
4243
from agents.matmaster_agent.flow_agents.model import PlanStepStatusEnum
4344
from agents.matmaster_agent.locales import i18n
4445
from agents.matmaster_agent.logger import PrefixFilter
46+
from agents.matmaster_agent.memory.inject_memory_callback import (
47+
inject_memory_before_model,
48+
)
49+
from agents.matmaster_agent.memory.store_tool_result_callback import (
50+
store_tool_result_in_memory,
51+
)
4552
from agents.matmaster_agent.model import CostFuncType
4653
from agents.matmaster_agent.state import PLAN
4754
from agents.matmaster_agent.style import tool_response_failed_card
@@ -84,6 +91,12 @@ def mcp_callback_model_validator(data: Any):
8491
if data.get('after_model_callback') is None:
8592
data['after_model_callback'] = default_after_model_callback
8693

94+
if data.get('before_model_callback') is None:
95+
data['before_model_callback'] = default_before_model_callback
96+
data['before_model_callback'] = inject_memory_before_model(
97+
data['before_model_callback']
98+
)
99+
87100
if data.get('before_tool_callback') is None:
88101
data['before_tool_callback'] = default_before_tool_callback
89102

@@ -118,11 +131,13 @@ def mcp_callback_model_validator(data: Any):
118131

119132
data['before_tool_callback'] = catch_before_tool_callback_error(pipeline)
120133

121-
data['after_tool_callback'] = check_before_tool_callback_effect(
122-
catch_after_tool_callback_error(
123-
remove_job_link(
124-
tgz_oss_to_oss_list(
125-
data['after_tool_callback'], data['enable_tgz_unpack']
134+
data['after_tool_callback'] = store_tool_result_in_memory(
135+
check_before_tool_callback_effect(
136+
catch_after_tool_callback_error(
137+
remove_job_link(
138+
tgz_oss_to_oss_list(
139+
data['after_tool_callback'], data['enable_tgz_unpack']
140+
)
126141
)
127142
)
128143
)

agents/matmaster_agent/core_agents/comp_agents/recommend_summary_agent/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
GLOBAL_SCHEMA_INSTRUCTION,
6464
get_vocabulary_enforce_prompt,
6565
)
66-
from agents.matmaster_agent.state import RECOMMEND_PARAMS
66+
from agents.matmaster_agent.state import RECOMMEND_PARAMS, STEP_DESCRIPTION
6767
from agents.matmaster_agent.sub_agents.tools import ALL_TOOLS
6868
from agents.matmaster_agent.utils.event_utils import (
6969
context_function_event,
@@ -214,7 +214,7 @@ async def _run_events(self, ctx: InvocationContext) -> AsyncGenerator[Event, Non
214214
)
215215

216216
self.tool_call_info_agent.instruction = gen_tool_call_info_instruction(
217-
user_prompt=current_step['description'],
217+
user_prompt=current_step[STEP_DESCRIPTION],
218218
agent_prompt=self.instruction,
219219
tool_doc=tool_doc,
220220
tool_schema=tool_schema,

agents/matmaster_agent/core_agents/comp_agents/recommend_summary_agent/subagent_summary_agent/callback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
MATMASTER_GENERATE_NPS,
1313
UNIVERSAL_CONTEXT_FILTER_KEYWORDS,
1414
)
15-
from agents.matmaster_agent.flow_agents.plan_info_agent.constant import PLAN_INFO_AGENT
1615
from agents.matmaster_agent.flow_agents.plan_make_agent.constant import PLAN_MAKE_AGENT
1716
from agents.matmaster_agent.logger import PrefixFilter
1817
from agents.matmaster_agent.utils.context_utils import is_content_has_keywords
@@ -30,7 +29,7 @@ async def filter_summary_llm_contents(
3029
if is_content_has_keywords(
3130
content,
3231
UNIVERSAL_CONTEXT_FILTER_KEYWORDS
33-
+ [PLAN_MAKE_AGENT, PLAN_INFO_AGENT]
32+
+ [PLAN_MAKE_AGENT]
3433
+ [MATMASTER_FLOW, MATMASTER_FLOW_PLANS, MATMASTER_GENERATE_NPS],
3534
):
3635
continue

agents/matmaster_agent/core_agents/comp_agents/recommend_summary_agent/tool_call_info_agent/prompt.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
from agents.matmaster_agent.utils.sanitize_braces import with_sanitized_braces
2+
3+
4+
@with_sanitized_braces('user_prompt', 'agent_prompt')
15
def gen_tool_call_info_instruction(
26
user_prompt, agent_prompt, tool_doc, tool_schema, tool_args_recommend_prompt
37
):
8+
user_prompt = user_prompt or ''
9+
agent_prompt = agent_prompt or ''
410
return f"""
511
You are an AI agent that matches user requests to available tools. Your task is to analyze the user's query against the complete parameter schema.
612

0 commit comments

Comments
 (0)