Skip to content

Fix pause event type - #144

Merged
xingyaoww merged 3 commits into
mainfrom
fix-pause
Sep 7, 2025
Merged

xingyaoww merged 3 commits into
mainfrom
fix-pause

Conversation

@malhotra5

@malhotra5 malhotra5 commented Sep 6, 2025 •

Copy link
Copy Markdown
Member

This PR fixes an error with pausing and confirmation mode working in conjunction.

Error description

  • Agent is generating action
  • User pauses
  • Pause event is generated
  • User resumes
  • We pick off where we left, ask user confirmation to execute action
  • Execute pending action
  • Have agent continue

The history will look like

[`ActionEvent`, `PauseEvent`, `ActionObservation`]  

However, when the agent tries to continue normally after the confirmation we get the following error

exception litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"messages.2: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01QKg9cpcJRs3hXQXxP2Ley1. Each `tool_use` block must have a corresponding `tool_result` block in the next message."},"request_id":"req_011CSsuHJbsCwyvuuhThHjEC"}

This occurs because we have a pause event in the middle of the action - observation pair. To fix this, we make sure that PauseEvent is not llm convertible. This way, it won't end up in the agent's history during llm completion and action observation pairs always match.

Before

image

After

image image

@github-actions

github-actions Bot commented Sep 6, 2025 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report
FileStmtsMissCoverMissing
openhands
   __init__.py10100% 
openhands/sdk
   __init__.py14285%22–23
   logger.py732171%33, 57, 64–67, 69–71, 124, 130–132, 135–136, 142–144, 151, 156–157
openhands/sdk/agent
   __init__.py30100% 
   base.py46491%36, 47, 83, 103
openhands/sdk/agent/agent
   __init__.py20100% 
   agent.py1262877%68–70, 127–128, 130–132, 134–136, 167, 181, 201, 229, 260–265, 272–273, 277–279, 306, 313
openhands/sdk/context
   __init__.py40100% 
   agent_context.py57296%146, 152
   manager.py330%1, 4–5
   view.py47687%46–50, 52
openhands/sdk/context/condenser
   __init__.py30100% 
   condenser.py17382%68–69, 73
   no_op_condenser.py60100% 
openhands/sdk/context/microagents
   __init__.py40100% 
   exceptions.py50100% 
   microagent.py1412979%129, 132–135, 209–215, 218, 223, 245–246, 251–252, 254, 258, 265–267, 275–277, 331, 333–334
   types.py300100% 
openhands/sdk/context/utils
   __init__.py20100% 
   prompt.py30583%12, 15, 24, 44–45
openhands/sdk/conversation
   __init__.py50100% 
   conversation.py83890%70, 78, 86–88, 92–93, 149
   state.py28292%47–48
   types.py30100% 
   visualizer.py1172082%46, 71, 84, 123–125, 128–129, 131, 154, 185, 189, 196, 199, 202–203, 226–228, 230
openhands/sdk/event
   __init__.py60100% 
   base.py642068%34, 38, 49, 53–55, 57–62, 64–65, 67–69, 71–72, 74
   condenser.py25580%29, 33–35, 49
   llm_convertible.py1011486%28–29, 34–35, 159–160, 165, 173, 205–206, 211, 226–227, 232
   types.py30100% 
   user_action.py6183%12
   utils.py110100% 
openhands/sdk/llm
   __init__.py50100% 
   exceptions.py360100% 
   llm.py39513964%249, 254, 267–269, 273–274, 306, 344, 348, 358, 364–365, 382–383, 452, 465–466, 471–472, 474–475, 477–480, 485–487, 491–493, 510–511, 514–516, 519–520, 528–529, 534, 537, 539–540, 544–545, 548–552, 562–565, 570–575, 579–580, 589–591, 594–595, 619, 625–626, 672, 699, 701, 707, 710, 719–720, 729, 736, 739, 743–745, 749, 751–756, 758–775, 778–782, 784–785, 791–800, 804–815
   llm_registry.py380100% 
   message.py100298%201–202
   metadata.py150100% 
openhands/sdk/llm/utils
   fn_call_converter.py34311267%74, 343, 345, 348–349, 367, 369, 375, 381, 383, 422, 424, 426, 428, 433–434, 481–482, 518–520, 522, 524, 545–547, 553, 575, 601–602, 610–613, 615, 617, 639, 648, 656, 701–704, 708–711, 723, 727, 738, 748, 794, 796–798, 800, 803, 819–821, 823–826, 829, 833, 844–845, 859, 866–867, 870–871, 875–876, 882–883, 886, 905–908, 912–913, 918–919, 924, 973–974, 980, 994, 1006, 1008–1009, 1012–1014, 1016–1017, 1023–1025, 1027–1028, 1030, 1032, 1036, 1038, 1043, 1045–1046, 1049
   metrics.py107298%17, 105
   model_features.py350100% 
   telemetry.py117794%72, 95, 100–101, 113–114, 209
openhands/sdk/mcp
   __init__.py50100% 
   client.py631182%41, 56–57, 78, 82, 94–95, 105–106, 112–113
   definition.py27196%54
   tool.py381365%33–36, 40, 43, 46–49, 89–90, 95
   utils.py30486%23–24, 27, 30
openhands/sdk/tool
   __init__.py40100% 
   schema.py89693%19–21, 23, 32, 191
   security_prompt.py30100% 
   tool.py821186%51, 107, 129, 149, 152–158
openhands/sdk/tool/builtins
   __init__.py30100% 
   finish.py150100% 
openhands/sdk/utils
   __init__.py20100% 
   json.py28280%1–3, 5, 7–8, 11, 14–21, 25, 28, 30–31, 34, 37–38, 40, 43, 45–48
   truncate.py100100% 
openhands/tools
   __init__.py8275%37–38
openhands/tools/execute_bash
   __init__.py40100% 
   constants.py90100% 
   definition.py411465%65, 69–78, 148, 151, 159
   impl.py10190%38
   metadata.py502354%67–73, 77–78, 83, 85, 87–96, 100–101
openhands/tools/execute_bash/terminal
   __init__.py60100% 
   factory.py492842%24–25, 30, 32, 35, 37–38, 44–46, 74–77, 79–83, 87–89, 91, 97, 107, 111–113
   interface.py661675%43, 52, 62, 71, 76, 85, 94, 99, 104, 112, 145, 157, 162, 171, 180, 185
   subprocess_terminal.py23620313%33–34, 50–53, 56, 59–61, 67–68, 70–73, 75, 78, 80–82, 96–99, 101, 104–105, 108, 111–112, 116–117, 123–125, 127, 130–131, 133, 137–138, 140–141, 143–149, 151–157, 160–165, 167–168, 170–171, 176, 178–186, 190–192, 194–195, 197–198, 201–203, 205–208, 210–211, 213–214, 216–221, 226–228, 230, 233, 236–237, 240–241, 247–249, 251–258, 260–263, 267–275, 288–289, 291, 308–309, 312–313, 315, 317, 319–321, 324–325, 327–329, 331–332, 334–335, 344–345, 349, 351–356, 360–361, 363–366, 368–374, 376–377, 379–383, 387–388, 390–396, 400–401, 404–405, 407–408, 410–412
   terminal_session.py17813623%43, 86, 92, 96–98, 107–108, 119–121, 123–126, 135–136, 140, 144, 147–148, 150, 155, 161, 163–164, 169, 177, 182–185, 198–200, 205, 208–209, 213, 219, 233–235, 240, 243–244, 248, 255, 264, 273–274, 276, 279–283, 285, 288, 290–292, 296–297, 300–302, 306, 311–312, 316–317, 323–325, 336–337, 340–342, 344–346, 349, 359, 363, 366, 369–370, 376–377, 383, 388–389, 392–396, 402, 404–406, 412–416, 419, 422, 425–426, 428–431, 438, 442, 447–448, 455–457, 461, 465, 470–471, 475–476, 479–482, 488–489, 492
   tmux_terminal.py752764%35, 41, 85, 97–98, 100, 108–109, 111, 118, 123, 135–142, 150–151, 153–154, 156, 158–160
openhands/tools/execute_bash/utils
   command.py817211%15–19, 27, 32, 34–35, 37–38, 41–46, 48, 51–53, 55, 58–67, 74–75, 77–79, 81, 83, 90–91, 93, 95–97, 99, 101–102, 105–106, 109, 117, 120–121, 123–124, 127–129, 132–138, 141–145, 150
openhands/tools/str_replace_editor
   __init__.py30100% 
   definition.py33487%78, 145, 148, 151
   editor.py22817025%74, 76–77, 80, 99, 102, 111–115, 121–129, 131, 149–150, 170–171, 175, 179–180, 189, 193–196, 204–205, 209–211, 217, 220, 225, 228, 231–232, 235, 238–239, 243, 247, 261–263, 272, 275, 281, 286, 288–292, 294, 296, 300–301, 305–306, 314–315, 317–320, 322, 328–329, 335–337, 345–349, 353, 355–356, 363, 366, 371–372, 374, 397–398, 420–421, 423–424, 430, 433, 437–443, 446–447, 450–455, 458, 461–462, 466, 469–470, 473, 475–476, 482, 486, 504, 509–512, 514, 522, 529, 536, 547–550, 552, 554, 580–583, 592–593, 622–624, 626–635, 640–643, 656–657, 662, 667, 673, 679
   exceptions.py221340%5–6, 9, 16–18, 25–27, 38–41
   impl.py261157%31–32, 49–50, 52–54, 63–66
openhands/tools/str_replace_editor/utils
   __init__.py00100% 
   config.py20100% 
   constants.py50100% 
   encoding.py542750%42–43, 46–48, 51, 54, 60, 64–65, 67, 69, 78, 80–81, 84, 87–90, 93, 96–97, 114, 128, 130–131
   file_cache.py954849%43–46, 49–50, 54, 59, 61, 64, 69, 72–73, 87, 95–98, 108–112, 115–120, 126–130, 133–135, 138–140, 143–148, 151, 154
   history.py663645%58–60, 66–68, 70–71, 74–76, 78–79, 82, 85–86, 88, 92–94, 98–99, 102–104, 107, 111–113, 115–120, 122
   shell.py231630%30, 32–34, 38, 40, 51–55, 62–63, 70–72
openhands/tools/utils
   __init__.py00100% 
TOTAL4026135666% 

@xingyaoww xingyaoww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about rename this as user_action.py?

@malhotra5

Copy link
Copy Markdown
Member Author

@OpenHands rename intervention.py to user_action.py

update any imports that reference the file

@openhands-ai

openhands-ai Bot commented Sep 7, 2025

Copy link
Copy Markdown

I'm on it! malhotra5 can track my progress at all-hands.dev

🟡 Solvability: MEDIUM

This is a straightforward file renaming task with clear instructions to rename intervention.py to user_action.py and update related imports. The request follows standard development patterns and has a well-defined scope, making it moderately solvable despite involving multiple components that need to be updated.

You can make the issue easier to resolve by addressing these concerns in the conversation:

• Provide specific details about which files or modules currently import intervention.py to help identify all locations that need updates
• Include information about the project structure or directory layout to better understand the scope of import changes needed
• Specify any testing requirements or validation steps needed after the renaming is complete

Positive feedback:

• The request uses clear, simple language that makes the required action immediately understandable
• This follows standard refactoring patterns that developers commonly encounter, making it familiar territory
• The task has a well-defined scope with specific steps (rename file, update imports) that can be systematically addressed

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai

openhands-ai Bot commented Sep 7, 2025

Copy link
Copy Markdown

Task completed successfully! I have renamed intervention.py to user_action.py and updated the import statement in __init__.py. The changes have been committed and pushed to the fix-pause branch, updating the existing PR #144. All functionality remains intact and the renaming is complete.

View full conversation

@xingyaoww xingyaoww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@xingyaoww
xingyaoww merged commit 6b3b577 into main Sep 7, 2025
@xingyaoww
xingyaoww deleted the fix-pause branch September 7, 2025 02:12
StressTestor pushed a commit to StressTestor/software-agent-sdk that referenced this pull request Jun 1, 2026
Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants