Repository navigation
test: unit tests for dynamic_prompting, generic_agent and reproducibility_agent - #61
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…lity_agent (feature: test coverage; xfail bug markers) Co-Authored-By: Daniella Grimberg <daniella@cognition.ai>
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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.
Summary
Adds hermetic unit tests for the GenericAgent stack — no browser, no LLM, no network, no real sleeps. Only three new test files; nothing in
src/or existing tests is touched.tests/agents/test_dynamic_prompting_unit.py(57 tests):Flagscopy/asdict/from_dict, visibility,Trunkater,fit_tokens(str / list /BaseMessage, shrink loop, max-iteration error),HTML/AXTree/Error/FocusedElement/Tabs,Observation+ screenshots,ActionPromptparsing and code-block fallback,Think,History,make_obs_preprocessor. Token counting is patched with a word count, so tiktoken never runs.tests/agents/test_generic_agent_unit.py(40 tests):GenericAgentArgs(name,set_benchmarkper benchmark, legacy flags,set_reproducibility_mode, prepare/close),GenericAgent.get_actiondriven by aFakeChatcallable (happy path, retries, busted retry, plan/memory/think history,fit_tokensdelegation),_check_flag_constancy,_get_maxes,MainPrompt, plusMemory/Plan/Criticiseparsing.tests/agents/test_reproducibility_agent_unit.py(30 tests):ReproChatModel(replay,<action>None</action>fallback,time.sleeppatched),ReproAgent.get_actionagainst synthetic exp dirs written withStepInfo.save_step_infointmp_path(replay, step indexing, no-chat-messages error page, rebuilding a missing response from the recorded action),_format_messages,_make_backward_compatible,_make_diff/_diff_stats/_set_style,make_repro_agentandreproduce_studyon a copy oftests/data/test_study/withStudystubbed out.Coverage (target modules)
dynamic_promptinggeneric_agent.generic_agentgeneric_agent.generic_agent_promptgeneric_agent.reproducibility_agentexcept AttributeErrorforCrossProdargs, is missed)146 test cases (127 test functions, some parametrized): 143 pass and 3 are strict xfails. The run took about 5s serially and about 6s with
-n 4.Source bugs (strict xfail, not fixed)
Flags.from_dictignoresclsand always buildsObsFlags, soActionFlags.from_dict(...)can't round-tripActionFlags(test_action_flags_from_dict_returns_action_flags).ReproChatModel.__call__copies theDiscussionshallowly (messages.copy()→Discussion.messagesis shared), soretry()appends the replayed answer twice. Replays reportn_retry=0.5, andchat_messagesholds a duplicate assistant message (test_replay_does_not_duplicate_answer)._diff_stats("", "")raisesZeroDivisionError(test_diff_stats_empty_strings).Commands
Note: the module-name form (
--cov=agentlab.agents.dynamic_prompting ...) fails during collection in this local env withRuntimeError: function '_has_torch_function' already has a docstring. That's torch being imported twice when coverage resolves the package before pytest does. It happens with the existingtests/agents/test_generic_prompt.pytoo, so it's an environment problem, not these tests. Pointing--covat the parent package (agentlab.agents, above) avoids that and reports the same per-file lines.Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/3d43817633ad4dc08eb787cbe65914f1
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/3d43817633ad4dc08eb787cbe65914f1?variant=devin
Requested by: @danigrim
Devin Review