|
8 | 8 | Message as LiteLLMMessage, |
9 | 9 | ModelResponse, |
10 | 10 | ) |
| 11 | +from pydantic import Field |
11 | 12 |
|
12 | 13 | from openhands.core.agenthub.agent import AgentBase |
13 | 14 | from openhands.core.agenthub.history import AgentHistory |
14 | 15 | from openhands.core.context.env_context import EnvContext |
15 | 16 | from openhands.core.context.prompt import PromptManager |
16 | 17 | from openhands.core.llm import LLM, Message, TextContent, get_llm_metadata |
17 | 18 | from openhands.core.logger import get_logger |
18 | | -from openhands.core.runtime import ActionBase, ObservationBase, Tool |
19 | | -from openhands.core.runtime.tools import FinishAction, finish_tool |
| 19 | +from openhands.core.tool import ActionBase, ObservationBase, Tool, ToolAnnotations |
20 | 20 |
|
21 | 21 |
|
22 | 22 | logger = get_logger(__name__) |
23 | 23 |
|
| 24 | +"""Finish tool implementation.""" |
| 25 | + |
| 26 | + |
| 27 | +class FinishAction(ActionBase): |
| 28 | + message: str = Field(description="Final message to send to the user.") |
| 29 | + |
| 30 | + |
| 31 | +TOOL_DESCRIPTION = """Signals the completion of the current task or conversation. |
| 32 | +
|
| 33 | +Use this tool when: |
| 34 | +- You have successfully completed the user's requested task |
| 35 | +- You cannot proceed further due to technical limitations or missing information |
| 36 | +
|
| 37 | +The message should include: |
| 38 | +- A clear summary of actions taken and their results |
| 39 | +- Any next steps for the user |
| 40 | +- Explanation if you're unable to complete the task |
| 41 | +- Any follow-up questions if more information is needed |
| 42 | +""" |
| 43 | + |
| 44 | + |
| 45 | +finish_tool = Tool( |
| 46 | + name="finish", |
| 47 | + input_schema=FinishAction, |
| 48 | + description=TOOL_DESCRIPTION, |
| 49 | + annotations=ToolAnnotations( |
| 50 | + title="finish", |
| 51 | + readOnlyHint=True, |
| 52 | + destructiveHint=False, |
| 53 | + idempotentHint=True, |
| 54 | + openWorldHint=False, |
| 55 | + ), |
| 56 | +) |
| 57 | + |
24 | 58 |
|
25 | 59 | class CodeActAgent(AgentBase): |
26 | 60 | def __init__( |
|
0 commit comments