Coverage for core/langgraph/tools/submit_decision.py: 91%

23 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-25 00:49 +0000

1"""Per-tool module for the synthetic `submit_decision` decision tool. 

2 

3This tool is not a real executor-registered builtin: the decision builtins 

4(`ticket-dor` / `ticket-review`) hand it to a synthetic inner agent whose real 

5call contract is an arbitrary decision payload. The definition here is the 

6permissive generic function-tool shape (empty `properties`, `additionalProperties` 

7true), and execution simply echoes the submitted arguments. 

8""" 

9from __future__ import annotations 

10 

11from typing import Any 

12 

13from .contract import ToolContext, ToolResult 

14 

15SUBMIT_DECISION_TOOL_NAME = "submit_decision" 

16 

17SUBMIT_DECISION_TOOL_TEXT = ( 

18 "Submit the structured decision object as the arguments of this tool call. " 

19 "Call this tool exactly once with the decision the system prompt defines; " 

20 "the message text carries no decision." 

21) 

22 

23 

24def definition() -> dict[str, Any]: 

25 """The permissive generic function-tool definition (single source).""" 

26 return { 

27 "type": "function", 

28 "function": { 

29 "name": SUBMIT_DECISION_TOOL_NAME, 

30 "description": SUBMIT_DECISION_TOOL_TEXT, 

31 "parameters": { 

32 "type": "object", 

33 "properties": {}, 

34 "additionalProperties": True, 

35 }, 

36 }, 

37 } 

38 

39 

40def submit_decision(args: dict, state: dict) -> dict: 

41 """Native submission tool: echo the submitted decision arguments.""" 

42 return args 

43 

44 

45class _SubmitDecisionTool: 

46 name = SUBMIT_DECISION_TOOL_NAME 

47 

48 def definition(self) -> dict[str, Any]: 

49 return definition() 

50 

51 def instruction(self) -> str | None: 

52 return None 

53 

54 def params(self) -> list[dict[str, Any]] | None: 

55 return None 

56 

57 def execute(self, context: ToolContext) -> ToolResult: 

58 try: 

59 from tools._ticket_common import _tool_content 

60 except ImportError: # pragma: no cover - main.py run (qualified imports) 

61 from langgraph.tools._ticket_common import _tool_content 

62 output = context.args or {} 

63 return ToolResult( 

64 ok=True, 

65 content=_tool_content(SUBMIT_DECISION_TOOL_NAME, ok=True, output=output), 

66 state_patch=None, 

67 ) 

68 

69 

70TOOL = _SubmitDecisionTool()