Commit 2c09065
committed
[Improvement] Autonomous loop: load tool schemas on demand via search_tools (kyegomez#1753)
get_autonomous_planning_tools() returns 16 tools totalling ~2,319 tokens
of schema, and max_loops="auto" front-loads all of them on every run.
Most tasks use three or four. Because the loop flattens context into one
ever-changing user message the block is never cached, so it is re-sent
and re-billed on every iteration, up to MAX_SUBTASK_ITERATIONS = 100.
selected_tools="lazy" ships a five-tool core -- create_plan,
subtask_done, complete_task, respond_to_user and the search_tools
meta-tool -- and lets the agent fetch the rest by intent:
search_tools("run a shell command") -> loads run_bash, grep
Measured on the current tool set: 2,319 -> 712 tokens resident, a 69%
reduction, and the resident cost now stays flat as tools are added
rather than growing with the catalogue.
Matching scores query words against tool name and description, so the
model describes what it wants instead of guessing exact names, which is
what made the existing selected_tools filter unusable for this -- it
required the caller to know the names up front.
A query that matches nothing returns the remaining tool *names* rather
than every remaining schema. Returning everything would mean one bad
search silently undoes the saving.
Defaults are untouched: selected_tools stays "all".1 parent f894187 commit 2c09065
3 files changed
Lines changed: 329 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
1980 | 1982 | | |
1981 | 1983 | | |
1982 | 1984 | | |
1983 | | - | |
1984 | | - | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
1985 | 1998 | | |
1986 | 1999 | | |
1987 | 2000 | | |
1988 | 2001 | | |
| 2002 | + | |
1989 | 2003 | | |
1990 | 2004 | | |
1991 | 2005 | | |
| |||
2097 | 2111 | | |
2098 | 2112 | | |
2099 | 2113 | | |
2100 | | - | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
2101 | 2121 | | |
2102 | 2122 | | |
| 2123 | + | |
2103 | 2124 | | |
2104 | 2125 | | |
2105 | 2126 | | |
| |||
5396 | 5417 | | |
5397 | 5418 | | |
5398 | 5419 | | |
5399 | | - | |
5400 | | - | |
| 5420 | + | |
5401 | 5421 | | |
5402 | 5422 | | |
5403 | 5423 | | |
5404 | 5424 | | |
5405 | 5425 | | |
5406 | 5426 | | |
5407 | | - | |
5408 | | - | |
| 5427 | + | |
5409 | 5428 | | |
5410 | 5429 | | |
5411 | 5430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
587 | 705 | | |
588 | 706 | | |
589 | 707 | | |
| |||
603 | 721 | | |
604 | 722 | | |
605 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
606 | 779 | | |
607 | 780 | | |
608 | 781 | | |
| |||
0 commit comments