Skip to content

support multiple callback fn; improve examples of how to add callback from script - #38

Merged
xingyaoww merged 2 commits into
mainfrom
xw/callback
Aug 28, 2025
Merged

xingyaoww merged 2 commits into
mainfrom
xw/callback

Conversation

@xingyaoww

Copy link
Copy Markdown
Contributor

…

@github-actions

github-actions Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report
FileStmtsMissCoverMissing
openhands/core
   __init__.py120100% 
   logger.py581475%24, 46–50, 52–54, 92–93, 99–101
openhands/core/agent
   __init__.py30100% 
   base.py371559%27–28, 31–37, 42, 47, 52, 57, 73, 91
openhands/core/agent/codeact_agent
   __init__.py20100% 
   codeact_agent.py957323%68–70, 74–75, 84–85, 87–92, 95, 99–109, 117–119, 124–125, 127–130, 132, 134–137, 139–141, 149–152, 154–159, 162–170, 173–176, 179–182, 188–191
openhands/core/config
   __init__.py30100% 
   llm_config.py591574%101, 104–107, 111–112, 117–118, 121–126
   mcp_config.py16110932%29–30, 32–45, 63, 85–86, 88, 91–92, 94, 100–101, 103, 106–107, 109, 123–125, 127, 130–132, 134, 136, 142–144, 146–150, 152–153, 155–160, 162–164, 173–175, 186, 206–209, 211–212, 217–219, 221–222, 224, 228, 231–232, 235–241, 253, 255, 257–262, 265–269, 271–276, 279–280, 283, 288–290, 293
openhands/core/context
   __init__.py60100% 
   env_context.py31874%74, 76–77, 83, 86–87, 90–91
   history.py10370%18–19, 22
   message_context.py9277%22, 25
   prompt.py362238%29, 32, 34–36, 53–54, 56–61, 75–79, 82–83, 93, 110
openhands/core/context/microagents
   __init__.py30100% 
   exceptions.py5180%11
   microagent.py13410025%39, 43–44, 46–47, 49, 52–54, 57–58, 67–68, 76–78, 81, 84–85, 87–88, 91–93, 95–97, 99–103, 106, 117–118, 120–123, 125–127, 131, 133, 135, 138, 140–141, 161–163, 170–173, 175, 179, 195–197, 208–210, 213, 218–219, 221–222, 229–231, 239–241, 246, 262–263, 265–266, 269–270, 272–274, 276, 279–284, 286–287, 289–291, 293–294, 296–297
   types.py300100% 
openhands/core/conversation
   __init__.py50100% 
   conversation.py412831%20–24, 34, 36, 39, 41–42, 46–47, 51–52, 54, 59, 61–64, 68–75
   state.py50100% 
   types.py50100% 
   visualizer.py544222%14, 18–23, 27, 29–31, 33, 35–36, 43, 45–47, 49, 56, 58, 60, 64–71, 73–74, 76, 78, 85, 90, 95–96, 99, 101, 108–109
openhands/core/llm
   __init__.py40100% 
   exceptions.py361363%5–6, 9, 16, 23, 30, 44, 52, 67, 77, 84, 94, 101
   llm.py33629412%93–97, 99–105, 109–117, 120–121, 123, 126, 130, 133–134, 136, 139–143, 145–146, 149–154, 156–157, 160–162, 164–166, 169–172, 176–177, 181, 183–184, 186, 199, 201, 209, 211, 213–214, 216–217, 221, 226–227, 230–232, 235, 238–239, 241–244, 246, 251, 254–255, 257–258, 262, 265, 268–269, 274, 277–278, 281, 287–289, 294, 297–299, 301, 304–306, 309, 312, 314–315, 317, 319–323, 326–327, 330, 333–335, 341, 351, 353, 356–359, 361, 363, 371, 374–381, 383, 386–388, 390, 395–403, 407–409, 412–414, 416–420, 422–423, 425, 427, 429, 431–432, 435–436, 439, 441–442, 444, 446–449, 452–454, 456, 459–461, 474, 484–485, 487, 494, 501–504, 506–507, 509, 515–517, 519–520, 522, 524–525, 527–528, 530–531, 534–537, 542–545, 548–551, 555, 565–566, 568, 580–581, 583, 587–588, 592–593, 600, 602–603, 611–618, 632–633, 635–637, 641–642, 645–649, 651–656, 658–667, 670–674, 677, 681–682, 685–694, 697
   message.py904846%22, 31, 35–37, 46–51, 73, 81–82, 84, 88–89, 92, 95–96, 98, 100, 103–108, 110, 112–117, 119–121, 123, 131–132, 145–148, 150, 155–156
   metadata.py151313%10, 12–14, 16–18, 20, 30–34
openhands/core/llm/utils
   fn_call_converter.py34230411%73–75, 335–348, 350–351, 353, 362–363, 365–368, 370–371, 373–374, 376–377, 379–382, 384–385, 387–388, 390, 397, 399, 420–427, 429–440, 442–447, 451–459, 461–464, 466, 468–470, 473, 476–478, 480, 482, 484–485, 494, 496–497, 499–503, 507–512, 514, 516–517, 520, 522–523, 526, 529, 531–535, 537, 559–560, 570–584, 586, 588–589, 592, 594–595, 597–601, 603, 605–606, 608, 610, 612–613, 621, 623–625, 627–629, 631–633, 636–639, 642–643, 647–657, 660, 663–665, 667–668, 671–674, 679–681, 683–684, 699, 711–713, 715–716, 718–721, 723–724, 726–728, 730–731, 733, 735–737, 739–745, 747–751, 753, 756–759, 764, 766–772, 774–775, 778, 787, 790–797, 799–802, 804, 806–809, 814–815, 818–819, 822–823, 829, 832–836, 838, 840, 843, 846–847, 855, 857–858, 861–863, 865–866, 872–874, 876–877, 879, 881–882, 884–885, 887–889
   metrics.py1146245%35, 57–63, 75, 79–81, 85, 89, 93, 97–99, 103, 107–109, 113, 118–119, 128, 131–134, 137, 150, 152, 162, 165, 178, 181–182, 184, 186–187, 190, 194, 205–209, 213, 226, 229, 232–234, 236, 239, 242, 245–246, 248, 259, 262
   model_features.py352042%17–20, 22, 25–28, 38–44, 46–48, 129
   retry_mixin.py504118%37, 39, 41–42, 45–49, 52–58, 60, 65, 76, 81–83, 85–88, 91–94, 97–98, 100–104, 107–109, 111
openhands/core/tool
   __init__.py20100% 
   schema.py71691%13–15, 17, 26, 135
   tool.py811482%49, 83–84, 97, 113, 130, 133–139, 157
openhands/tools
   __init__.py80100% 
openhands/tools/execute_bash
   __init__.py30100% 
   bash_session.py2031592%59, 249–255, 262, 298, 312, 331, 339, 449–450
   constants.py90100% 
   definition.py34294%58, 60
   impl.py9366%13–14, 17
   metadata.py50394%81–83
openhands/tools/execute_bash/utils
   command.py81495%44, 60–62
openhands/tools/str_replace_editor
   __init__.py30100% 
   definition.py29389%57–59
   editor.py2283385%90, 101, 103, 111, 113, 118, 227–228, 236–237, 240, 244, 246–250, 252, 254–258, 289, 298, 340–341, 457, 555, 560–561, 575–576
   exceptions.py220100% 
   impl.py26869%18, 21–23, 32–35
openhands/tools/str_replace_editor/utils
   __init__.py00100% 
   config.py20100% 
   encoding.py54198%73
   file_cache.py95990%39–45, 117, 120
   history.py66198%74
   prompts.py40100% 
   shell.py240100% 
   truncate.py40100% 
openhands/tools/utils
   __init__.py00100% 
   security_prompt.py30100% 
TOTAL2937132954% 

@xingyaoww
xingyaoww merged commit 855160a into main Aug 28, 2025
@xingyaoww
xingyaoww deleted the xw/callback branch August 28, 2025 03:30
Comment thread examples/hello_world.py
Comment on lines +50 to +58
def conversation_callback(event: ConversationEventType):
# print all the actions
if isinstance(event, ActionBase):
logger.info(f"Found a conversation action: {event}")
elif isinstance(event, ObservationBase):
logger.info(f"Found a conversation observation: {event}")
elif isinstance(event, Message):
logger.info(f"Found a conversation message: {str(event)[:200]}...")
llm_messages.append(event.model_dump())

@malhotra5 malhotra5 Aug 28, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe this should be a default callback that we expose through the conversation object (with the option to override it)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wdym? the default callback now is actually the visualizer callback that print stuff 🤔

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.

2 participants