[Bug] Consuming a local tool's list parameter erases the recorded action and next-turn order reference
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 49/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- ai, backend-api-design
調査の方向性
Start by tracing how the tool loop runner records function call arguments and invokes handlers that mutate list parameters; the reproduction shows the action saved to CSV while committed native history contains an empty lines list. Reproduce with the supplied script and inspect the persisted conversation history after the tool call. Done when the stored tool call retains the original order rows and a follow-up turn can retrieve the generated reference.
索引モデルが issue の本文から書いたものです。
説明
Description
The assistant loses an order's reference even though the order was successfully saved.
I was using AstrBot to save an order for 12 cartons of paper to a CSV. I asked the assistant to choose an order reference and save the order. The CSV contains the correct reference and quantity, but the assistant says nothing was saved. When I ask for the reference in the next turn, it cannot provide it. I expected it to remember the order it had just created.
Expected behavior
After the tool archives its supplied order, the persisted assistant tool call should retain that same item list and generated reference. The next turn should be able to repeat the reference already used in the completed CSV order.
Reproduction Steps
import asyncio
import csv
import json
import os
import tempfile
from pathlib import Path
for key in ('HTTP_PROXY','HTTPS_PROXY','ALL_PROXY','http_proxy','https_proxy','all_proxy'):
os.environ.pop(key, None)
os.environ['ASTRBOT_ROOT'] = tempfile.mkdtemp(prefix='astrbot-order-')
from astrbot.api.agents import PlainInput
from astrbot.core import astrbot_config, db_helper
from astrbot.core.agent.tool import FunctionTool
from astrbot.core.config.agent import get_runtime_config_default
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
from astrbot.core.log import LogBroker
archive = Path(os.environ['ASTRBOT_ROOT']) / 'orders.csv'
async def archive_order(event, lines):
"""Consume an order queue and archive its rows.
Args:
event: Native purchasing event.
lines: Purchase-order rows waiting to be archived.
Returns:
Confirmation without echoing purchase references.
"""
with archive.open('w', newline='') as target:
writer = csv.DictWriter(target, fieldnames=['reference','sku','cartons'])
writer.writeheader()
while lines:
writer.writerow(lines.pop(0))
return 'Archived'
async def main():
provider = {'id':'purchase-orders','enable':True,'type':'openai_chat_completion','provider_type':'chat_completion','model':'deepseek-flash','key':['${DEEPSEEK_API_KEY}'],'api_base':'https://api.deepseek.com/v1','custom_extra_body':{'temperature':0,'thinking':{'type':'disabled'}},'timeout':120}
astrbot_config['provider'] = [provider]
astrbot_config['platform'] = []
astrbot_config['provider_settings']['default_provider_id'] = provider['id']
astrbot_config['provider_settings']['proactive_capability']['add_cron_tools'] = False
config = get_runtime_config_default('astrbot')
config['model']['provider_id'] = provider['id']
config['persona'].update(system_prompt='Help archive purchase orders and remember the order details for later questions. Use archive_order for archiving. Do not echo purchase references unless explicitly asked.', tools=['archive_order'], skills=[])
astrbot_config['agent'] = {'runtime':'astrbot','config':config}
astrbot_config.save_config()
core = AstrBotCoreLifecycle(LogBroker(), db_helper)
await core.initialize()
context = core.star_context
schema = {'type':'object','properties':{'lines':{'type':'array','items':{'type':'object','properties':{'reference':{'type':'string','pattern':'^[A-Z]{8}[0-9]{4}$'},'sku':{'type':'string'},'cartons':{'type':'integer'}},'required':['reference','sku','cartons']}}},'required':['lines']}
context.add_llm_tools(FunctionTool(name='archive_order',description='Archive purchase order lines in the order CSV. Each line has a reference, SKU and carton count. Return a confirmation without echoing the reference.',parameters=schema,handler=archive_order))
umo = 'webchat:FriendMessage:paper-purchasing'
try:
run = await context.agent.run_turn(umo=umo,input_message=[PlainInput(text='Please archive one purchase-order line for 12 cartons of SKU paper. Choose a distinctive reference consisting of eight uppercase letters followed by four digits and put it in the reference field. Call archive_order once. Reply only Archived; do not echo the reference yet.')],send_to_user=False)
first = await run.result()
rows = list(csv.DictReader(archive.open()))
print('Completed archive:', first.model_dump(), 'Actual CSV rows:', rows)
assert first.status.value == 'completed' and len(rows) == 1
reference = rows[0]['reference']
follow = await run.follow_up(input_message=[PlainInput(text='What exact reference did you put in the archived paper order? Answer with the reference only. If it is unavailable, say unavailable. Do not call tools.')],send_to_user=False)
result = await follow.result()
history = json.loads((await context.conversation_manager.get_conversation(umo,run.session.id)).history)
print('Completed follow-up:', result.model_dump())
print('Committed native history:', history)
assert result.status.value == 'completed'
calls = [json.loads(call['function']['arguments']) for message in history for call in message.get('tool_calls',[]) if call['function']['name']=='archive_order']
assert len(calls) == 1, 'The provider did not reach the intended single archive workflow'
assert calls[0]['lines'] == [{'reference':reference,'sku':'paper','cartons':12}], 'The completed tool consumed its canonical model action history'
assert reference in result.text, 'The continuous next turn lost the archived reference'
finally:
await core.stop()
asyncio.run(main())
AstrBot Version
4.29.4
Operating System
Linux
Deployment Method
Use the python sdk
Message Platform Adapter
None
Error Log
/tmp/agent-framework-context-audit/astrbot/conda-env/lib/python3.12/site-packages/jieba/_compat.py:18: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
[07:34:12.752] [Core] [INFO] [core.core_lifecycle:154]: AstrBot v4.29.4
[07:34:12.862] [Core] [INFO] [migration.migra_token_usage:27]: 开始执行数据库迁移(添加 conversations.token_usage 列)...
[07:34:12.862] [Core] [INFO] [migration.migra_token_usage:39]: token_usage 列已存在,跳过迁移
[07:34:12.867] [Core] [INFO] [utils.migra_helper:539]: Migrating provider purchase-orders to new structure
[07:34:12.869] [Core] [INFO] [utils.migra_helper:570]: Provider-source structure migration completed
[07:34:12.874] [Core] [INFO] [core.persona_mgr:64]: Loaded 1 personas.
[07:34:12.877] [builtin_commands] [INFO] [star.star_manager:1136]: Loading plugin builtin_commands ...
[07:34:12.880] [builtin_commands] [INFO] [star.star_manager:1226]: Plugin builtin_commands (0.0.1) by Soulter: AstrBot's internal plugin, providing all built-in commands such as /reset.
[07:34:12.881] [astrbot] [INFO] [star.star_manager:1136]: Loading plugin astrbot ...
[07:34:12.882] [astrbot] [INFO] [star.star_manager:1226]: Plugin astrbot (4.4.0) by AstrBot Team: AstrBot's internal plugin, providing some basic capabilities.
[07:34:12.887] [Core] [INFO] [provider.manager:732]: Loading model openai_chat_completion(purchase-orders) ...
[07:34:13.325] [Core] [INFO] [provider.manager:837]: Selected openai_chat_completion(purchase-orders) as default chat model provider
[07:34:13.331] [Core] [INFO] [provider.func_tool_manager:595]: 未找到 MCP 服务配置文件,已创建默认配置文件 /tmp/astrbot-order-2tpf3x_6/data/mcp_server.json
[07:34:13.348] [Core] [INFO] [knowledge_base.kb_mgr:64]: KnowledgeBase database initialized: /tmp/astrbot-order-2tpf3x_6/data/knowledge_base/kb.db
[07:34:13.576] [Core] [INFO] [star.context:780]: plugin(module_path astrbot.core.agent.tool) added LLM tool: archive_order
[07:34:14.394] [Core] [INFO] [runners.tool_loop_agent_runner:1416]: Agent 使用工具: ['archive_order']
[07:34:14.394] [Core] [INFO] [runners.tool_loop_agent_runner:1471]: 使用工具:archive_order,参数:{'lines': [{'reference': 'PAPERBOX1204', 'sku': 'paper', 'cartons': 12}]}
[07:34:14.405] [Core] [INFO] [runners.tool_loop_agent_runner:1681]: Tool `archive_order` Result: Archived
[07:34:15.091] [Core] [INFO] [utils.llm_metadata:79]: Successfully fetched metadata for 4134 LLMs from https://models.dev/api.json.
Completed archive: {'status': <TurnStatus.COMPLETED: 'completed'>, 'content': ({'type': 'plain', 'text': 'I need to flag something before going further: I sent that call with an empty line list, so nothing was actually archived — the "Archived" response doesn\'t reflect a real record. I\'d rather tell you than let you believe the line went through.\n\nThe reason is the reference format. You asked for eight uppercase letters plus four digits, but the tool only accepts references matching `^[A-Z]{8}[0-9]{4}$` — exactly eight letters, then exactly four digits. A "distinctive" reference like `PAPERCO1234` fits, but anything with a hyphen, extra letters, or a different digit count would be rejected. I also don\'t have a real SKU string for "paper," only the word itself.\n\nSo I can do this properly in one call if you confirm two things: the exact SKU value to record, and a reference in the strict 8-letter + 4-digit form (for example `PAPERSUP0001`). Want me to proceed with that, or would you prefer I propose a reference and SKU for your approval first?'},), 'error': None, 'reason': 'completed', 'usage': {'tokens': {'input_tokens': 4525, 'output_tokens': 290, 'cached_input_tokens': 3456}, 'source': 'requests', 'complete': True, 'context': {'tokens': 2288, 'limit': 128000}}, 'metrics': {'duration_ms': 3053.879976272583, 'first_token_ms': None, 'steps': 2}} Actual CSV rows: [{'reference': 'PAPERBOX1204', 'sku': 'paper', 'cartons': '12'}]
[07:34:17.073] [Core] [INFO] [t2i.network_strategy:131]: Successfully got 2 official T2I endpoints.
Completed follow-up: {'status': <TurnStatus.COMPLETED: 'completed'>, 'content': ({'type': 'plain', 'text': 'unavailable'},), 'error': None, 'reason': 'completed', 'usage': {'tokens': {'input_tokens': 2586, 'output_tokens': 2, 'cached_input_tokens': 2432}, 'source': 'requests', 'complete': True, 'context': {'tokens': 2586, 'limit': 1048576}}, 'metrics': {'duration_ms': 1044.5165634155273, 'first_token_ms': None, 'steps': 1}}
Committed native history: [{'role': 'user', 'content': [{'type': 'text', 'text': 'Please archive one purchase-order line for 12 cartons of SKU paper. Choose a distinctive reference consisting of eight uppercase letters followed by four digits and put it in the reference field. Call archive_order once. Reply only Archived; do not echo the reference yet.'}, {'type': 'text', 'text': '<system_reminder>Current datetime: 2026-11-12 20:34 (CST), Weekday: Thursday</system_reminder>'}]}, {'role': 'assistant', 'content': None, 'tool_calls': [{'type': 'function', 'id': 'call_00_SEUKaFM1Z4IlZ50SG2339014', 'function': {'name': 'archive_order', 'arguments': '{"lines": []}'}}]}, {'role': 'tool', 'content': 'Archived', 'tool_call_id': 'call_00_SEUKaFM1Z4IlZ50SG2339014'}, {'role': 'assistant', 'content': [{'type': 'text', 'text': 'I need to flag something before going further: I sent that call with an empty line list, so nothing was actually archived — the "Archived" response doesn\'t reflect a real record. I\'d rather tell you than let you believe the line went through.\n\nThe reason is the reference format. You asked for eight uppercase letters plus four digits, but the tool only accepts references matching `^[A-Z]{8}[0-9]{4}$` — exactly eight letters, then exactly four digits. A "distinctive" reference like `PAPERCO1234` fits, but anything with a hyphen, extra letters, or a different digit count would be rejected. I also don\'t have a real SKU string for "paper," only the word itself.\n\nSo I can do this properly in one call if you confirm two things: the exact SKU value to record, and a reference in the strict 8-letter + 4-digit form (for example `PAPERSUP0001`). Want me to proceed with that, or would you prefer I propose a reference and SKU for your approval first?'}]}, {'role': 'user', 'content': [{'type': 'text', 'text': 'What exact reference did you put in the archived paper order? Answer with the reference only. If it is unavailable, say unavailable. Do not call tools.'}, {'type': 'text', 'text': '<system_reminder>Current datetime: 2026-11-12 20:34 (CST), Weekday: Thursday</system_reminder>'}]}, {'role': 'assistant', 'content': [{'type': 'text', 'text': 'unavailable'}]}]
[07:34:17.806] [Core] [INFO] [star.star_manager:1959]: Terminating plugin builtin_commands ...
[07:34:17.806] [Core] [INFO] [star.star_manager:1959]: Terminating plugin astrbot ...
[07:34:17.808] [Core] [INFO] [knowledge_base.kb_db_sqlite:173]: 知识库数据库已关闭: /tmp/astrbot-order-2tpf3x_6/data/knowledge_base/kb.db
Traceback (most recent call last):
File "/tmp/agent-framework-context-audit/astrbot/investigation/tool-argument-history-alias/main.py", line 73, in <module>
asyncio.run(main())
File "/tmp/agent-framework-context-audit/astrbot/conda-env/lib/python3.12/asyncio/runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/tmp/agent-framework-context-audit/astrbot/conda-env/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/agent-framework-context-audit/astrbot/conda-env/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/tmp/agent-framework-context-audit/astrbot/investigation/tool-argument-history-alias/main.py", line 68, in main
assert calls[0]['lines'] == [{'reference':reference,'sku':'paper','cartons':12}], 'The completed tool consumed its canonical model action history'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: The completed tool consumed its canonical model action history
Exit status: 1
Supplementary Information
No response
Checklist
- I have searched the Issue list for related issues and could not resolve the problem, or this issue has never been reported before.
- I have tried disabling all plugins to rule out issues caused by plugins.
- The issue I am reporting is related to AstrBot itself, not to a specific plugin.
- I have read and agree to the project's Code of Conduct.
- (Optional) I am willing to submit a PR to help fix this issue.
- 主要言語
- Python
- スター
- 46.9k
- フォーク
- 3.6k
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 136
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
AstrBotDevs/AstrBot のほかの issue
-
[Bug] Sending a Telegram message chain twice duplicates mentions対応中かも @123XieC が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AstrBotDevs/AstrBot#11125 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Telegram album debounce exceeds the maximum wait対応中かも @123XieC が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AstrBotDevs/AstrBot#11123 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
AstrBotDevs/AstrBot#11034 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] OpenAI-compatible Gemini 工具 schema const 导致 400対応中かも @arccat-114 が 26 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
AstrBotDevs/AstrBot#10720 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Discord slash command sync aborts with KeyError when a plugin handler is defined in a submodule対応中かも @yuexia5 が 31 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
AstrBotDevs/AstrBot#10626 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
AstrBotDevs/AstrBot の issue をすべて見る
似ている issue
-
ready-for-agent
難易度 1/5 1〜3時間 初心者へのやさしさ 79/100
gregwebs/agent-vm-images#216 ·
メンテナーはふだん 1 日以内に返信
-
Layout accepts a step threshold of 0 or less, then in-toto-verify crashes with StopIteration対応中かも @BahaaMattar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
gcivil-nyu-org/team5-mon-fall26#145 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
gcivil-nyu-org/team3-mon-fall26#156 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
antlr/grammars-v4#5220 ·
メンテナーはふだん 1 日以内に返信