fix: persist agent app uploads as message files - #40889
Open
Elliott-byte wants to merge 2 commits into
Open
Conversation
Agent apps built the generate entity with files=[], so user uploads were never persisted as MessageFile records and disappeared from the conversation history UI after a reload, in both the build preview and the published app. Parse the request file mappings into File entities (same pattern as agent-chat) so the chat pipeline persists them; the agent backend keeps consuming only the prompt locators. Fixes langgenius#40874
Contributor
Pyrefly Type Coverage
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-08-17 12:10:59.090912731 +0000
+++ /tmp/pyrefly_pr.txt 2026-08-17 12:10:51.442851273 +0000
@@ -3187,13 +3187,13 @@
ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
--> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:73:22
ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:183:18
+ --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:189:18
ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:229:18
+ --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:235:18
ERROR Object of class `FunctionType` has no attribute `call_args` [missing-attribute]
- --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:321:16
+ --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:327:16
ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
- --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:389:25
+ --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:395:25
ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
--> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:67:12
ERROR Object of class `NoneType` has no attribute `prompt_messages` [missing-attribute]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #40874
Summary
Agent apps (New Agent Beta) built the generate entity with
files=[]: user uploads were forwarded to the agent backend through the prompt locators (prompt_file_mappings), but never parsed intoFileentities, so_init_generate_recordsnever persistedMessageFilerows for them. As a result, uploaded files vanished from the conversation history UI as soon as the chat was reloaded — in both the build preview and the published app. This is the remaining UI symptom in #40874 (the request-side attachment drop from the same report was already fixed by #40179).This change parses the request file mappings into
Fileentities inside the file-access scope — the same patternagent_chatuses — and passes them toAgentAppGenerateEntity, so the chat pipeline persistsMessageFilerecords and history APIs return the uploads again. The agent backend keeps consuming only the prompt locators; the agent app runner and task pipeline never readentity.files, so the change is purely additive on the persistence side. The HITL resume path still passesfiles=[], since a resume carries no new uploads.One deliberate behavior change: an invalid
upload_file_idnow fails the request (consistent withchat/agent_chat) instead of being silently dropped.Verified with the updated unit test in
tests/unit_tests/core/app/apps/agent_app/test_app_generator.py(uploads must reach the entity asFileobjects), plus the fulltests/unit_tests/core/app/apps/suite (578 passed).Screenshots
message_filespersisted and rendered in historyChecklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint godsFrom Claude Code and me