Skip to content

Commit 468a332

Browse files
authored
Merge branch 'develop' into revert-892-revert-888-tawsif/sentry-error-tool-call
2 parents 7fe4cb5 + 5f91de7 commit 468a332

File tree

17 files changed

+161
-51
lines changed

17 files changed

+161
-51
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env.db

docs/api-reference/core/Codebase.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {HorizontalDivider} from '/snippets/HorizontalDivider.mdx';
1111
import {GithubLinkNote} from '/snippets/GithubLinkNote.mdx';
1212
import {Attribute} from '/snippets/Attribute.mdx';
1313

14-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L117-L1561" />
14+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L117-L1566" />
1515

1616

1717
## Attributes
@@ -89,7 +89,7 @@ import {Attribute} from '/snippets/Attribute.mdx';
8989
<HorizontalDivider />
9090
### <span className="text-primary">ai</span>
9191
Generates a response from the AI based on the provided prompt, target, and context.
92-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1192-L1279" />
92+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1196-L1283" />
9393

9494
<ParameterWrapper>
9595
<Parameter
@@ -124,7 +124,7 @@ Generates a response from the AI based on the provided prompt, target, and conte
124124

125125
### <span className="text-primary">checkout</span>
126126
Checks out a git branch or commit and syncs the codebase graph to the new state.
127-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L865-L905" />
127+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L865-L909" />
128128

129129
<ParameterWrapper>
130130
<Parameter
@@ -234,7 +234,7 @@ Creates a new file in the codebase with specified content.
234234

235235
### <span className="text-primary">create_pr</span>
236236
Creates a pull request from the current branch to the repository's default branch.
237-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L970-L1002" />
237+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L974-L1006" />
238238

239239
<ParameterWrapper>
240240
<Parameter
@@ -257,15 +257,15 @@ Creates a pull request from the current branch to the repository's default branc
257257

258258
### <span className="text-primary">create_pr_comment</span>
259259
Create a comment on a pull request
260-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1533-L1535" />
260+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1538-L1540" />
261261

262262

263263
<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description=""/>
264264

265265

266266
### <span className="text-primary">create_pr_review_comment</span>
267267
Create a review comment on a pull request.
268-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1537-L1561" />
268+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1542-L1566" />
269269

270270

271271
<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description=""/>
@@ -281,7 +281,7 @@ A list property that returns all files in the codebase.
281281

282282
### <span className="text-primary">find_by_span</span>
283283
Finds editable objects that overlap with the given source code span.
284-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1289-L1304" />
284+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1293-L1308" />
285285

286286
<ParameterWrapper>
287287
<Parameter
@@ -298,15 +298,15 @@ Finds editable objects that overlap with the given source code span.
298298

299299
### <span className="text-primary">from_files</span>
300300
Creates a Codebase instance from multiple files.
301-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1443-L1523" />
301+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1448-L1528" />
302302

303303

304304
<Return return_type={ <><a href="/api-reference/core/Codebase" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Codebase</a></> } description="A Codebase instance initialized with the provided files"/>
305305

306306

307307
### <span className="text-primary">from_repo</span>
308308
Fetches a codebase from GitHub and returns a Codebase instance.
309-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1327-L1394" />
309+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1331-L1398" />
310310

311311
<ParameterWrapper>
312312
<Parameter
@@ -359,7 +359,7 @@ Fetches a codebase from GitHub and returns a Codebase instance.
359359

360360
### <span className="text-primary">from_string</span>
361361
Creates a Codebase instance from a string of code.
362-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1397-L1440" />
362+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1401-L1445" />
363363

364364

365365
<Return return_type={ <><a href="/api-reference/core/Codebase" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Codebase</a></> } description="A Codebase instance initialized with the provided code Example: >>> # Python code >>> code = &quot;def add(a, b): return a + b&quot; >>> codebase = Codebase.from_string(code, language=&quot;python&quot;) >>> # TypeScript code >>> code = &quot;function add(a: number, b: number): number { return a + b; }&quot; >>> codebase = Codebase.from_string(code, language=&quot;typescript&quot;)"/>
@@ -465,7 +465,7 @@ Retrieves a function from the codebase by its name.
465465

466466
### <span className="text-primary">get_modified_symbols_in_pr</span>
467467
Get all modified symbols in a pull request
468-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1525-L1531" />
468+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1530-L1536" />
469469

470470

471471
<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">tuple[str, dict[str, str], list[str]]</code> } description=""/>
@@ -624,15 +624,15 @@ Resets the codebase by
624624

625625
### <span className="text-primary">set_ai_key</span>
626626
Sets the OpenAI key for the current Codebase instance.
627-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1281-L1287" />
627+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1285-L1291" />
628628

629629

630630
<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description=""/>
631631

632632

633633
### <span className="text-primary">set_session_options</span>
634634
Sets the session options for the current codebase.
635-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1306-L1324" />
635+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1310-L1328" />
636636

637637
<ParameterWrapper>
638638
<Parameter
@@ -661,7 +661,7 @@ Sets the session options for the current codebase.
661661

662662
### <span className="text-primary">should_fix</span>
663663
Returns True if the flag should be fixed based on the current mode and active group.
664-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1056-L1070" />
664+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1060-L1074" />
665665

666666
<ParameterWrapper>
667667
<Parameter
@@ -678,7 +678,7 @@ Returns True if the flag should be fixed based on the current mode and active gr
678678

679679
### <span className="text-primary">visualize</span>
680680
Visualizes a NetworkX graph or Plotly figure.
681-
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1008-L1021" />
681+
<GithubLinkNote link="https://github.com/codegen-sh/codegen/blob/develop/src/codegen/sdk/core/codebase.py#L1012-L1025" />
682682

683683
<ParameterWrapper>
684684
<Parameter

docs/changelog/changelog.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,49 @@ icon: "clock"
44
iconType: "solid"
55
---
66

7+
<Update label="v0.52.8" description="March 18, 2025">
8+
### [Update OpenAI dependency to improve stability.](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.8)
9+
- Update OpenAI dependency to v1.66.5
10+
</Update>
11+
12+
<Update label="v0.52.7" description="March 18, 2025">
13+
### [Improved documentation and fixed log issues.](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.7)
14+
- Updated API reference documentation
15+
- Fixed logging for empty repositories and codebase parsing
16+
</Update>
17+
18+
<Update label="v0.52.6" description="March 18, 2025">
19+
### [Fixes commit attribution issue](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.6)
20+
- Fix commit attribution issue with codegen-sh
21+
</Update>
22+
23+
<Update label="v0.52.5" description="March 18, 2025">
24+
### [Tool update to include default parameter values.](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.5)
25+
- Update tool to include default parameter values
26+
</Update>
27+
28+
29+
<Update label="v0.52.4" description="March 18, 2025">
30+
### [Fixes parameter reference bug.](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.4)
31+
- Fixed parameter reference bug
32+
</Update>
33+
34+
35+
<Update label="v0.52.3" description="March 18, 2025">
36+
### [enhances search by filename tool with pagination.](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.3)
37+
- Update search by filename tool to support pagination
38+
</Update>
39+
40+
41+
<Update label="v0.52.2" description="March 18, 2025">
42+
### [Enhances agent and tools, increases token limit.](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.2)
43+
- Increased view file size limit for better usability
44+
- Enhanced agent functionality to accept image URLs
45+
- Fixed multiple broken links
46+
- Increased output token limit for better performance
47+
- Introduced schemas for tool outputs
48+
</Update>
49+
750
<Update label="v0.52.1" description="March 17, 2025">
851
### [Fixes an error in the search files by name tool.](https://github.com/codegen-sh/codegen-sdk/releases/tag/v0.52.1)
952
- Fix error in search files by name tool

docs/gen/introduction.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ Codegen is an intelligent code agent powered that seamlessly integrates with Sla
1818

1919
# Installation
2020

21-
[Log in with GitHub](https://codegen.sh/start) to install Codegen and set up integrations.
21+
[Log in with GitHub](https://codegen.sh/install) to install Codegen and set up integrations.
2222

23-
<Card title="Get Started" href={"https://codegen.sh/start"} icon="Gear">
23+
<Card title="Get Started" href={"https://codegen.sh/install"} icon="Gear">
2424
Install codegen via OAuth with Github, Slack and Linear
2525
</Card>
2626

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readme = "README.md"
66
# renovate: datasource=python-version depName=python
77
requires-python = ">=3.12, <3.14"
88
dependencies = [
9-
"openai==1.66.3",
9+
"openai==1.66.5",
1010
"tiktoken<1.0.0,>=0.5.1",
1111
"tabulate>=0.9.0,<1.0.0",
1212
"codeowners<1.0.0,>=0.6.0",

src/codegen/extensions/langchain/llm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def _get_model(self) -> BaseChatModel:
8989
if not os.getenv("ANTHROPIC_API_KEY"):
9090
msg = "ANTHROPIC_API_KEY not found in environment. Please set it in your .env file or environment variables."
9191
raise ValueError(msg)
92-
return ChatAnthropic(**self._get_model_kwargs(), max_tokens=8192, max_retries=10, timeout=1000)
92+
max_tokens = 16384 if "claude-3-7" in self.model_name else 8192
93+
return ChatAnthropic(**self._get_model_kwargs(), max_tokens=max_tokens, max_retries=10, timeout=1000)
9394

9495
elif self.model_provider == "openai":
9596
if not os.getenv("OPENAI_API_KEY"):
@@ -101,7 +102,7 @@ def _get_model(self) -> BaseChatModel:
101102
if not os.getenv("XAI_API_KEY"):
102103
msg = "XAI_API_KEY not found in environment. Please set it in your .env file or environment variables."
103104
raise ValueError(msg)
104-
return ChatXAI(**self._get_model_kwargs(), max_tokens=8192)
105+
return ChatXAI(**self._get_model_kwargs(), max_tokens=12000)
105106

106107
msg = f"Unknown model provider: {self.model_provider}. Must be one of: anthropic, openai, xai"
107108
raise ValueError(msg)

src/codegen/extensions/langchain/tools.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ViewFileInput(BaseModel):
5656
filepath: str = Field(..., description="Path to the file relative to workspace root")
5757
start_line: Optional[int] = Field(None, description="Starting line number to view (1-indexed, inclusive)")
5858
end_line: Optional[int] = Field(None, description="Ending line number to view (1-indexed, inclusive)")
59-
max_lines: Optional[int] = Field(None, description="Maximum number of lines to view at once, defaults to 250")
59+
max_lines: Optional[int] = Field(None, description="Maximum number of lines to view at once, defaults to 500")
6060
line_numbers: Optional[bool] = Field(True, description="If True, add line numbers to the content (1-indexed)")
6161
tool_call_id: Annotated[str, InjectedToolCallId]
6262

@@ -66,7 +66,7 @@ class ViewFileTool(BaseTool):
6666

6767
name: ClassVar[str] = "view_file"
6868
description: ClassVar[str] = """View the contents and metadata of a file in the codebase.
69-
For large files (>250 lines), content will be paginated. Use start_line and end_line to navigate through the file.
69+
For large files (>500 lines), content will be paginated. Use start_line and end_line to navigate through the file.
7070
The response will indicate if there are more lines available to view."""
7171
args_schema: ClassVar[type[BaseModel]] = ViewFileInput
7272
codebase: Codebase = Field(exclude=True)
@@ -89,7 +89,7 @@ def _run(
8989
line_numbers=line_numbers if line_numbers is not None else True,
9090
start_line=start_line,
9191
end_line=end_line,
92-
max_lines=max_lines if max_lines is not None else 250,
92+
max_lines=max_lines if max_lines is not None else 500,
9393
)
9494

9595
return result.render(tool_call_id)
@@ -1100,14 +1100,16 @@ class SearchFilesByNameInput(BaseModel):
11001100
"""Input for searching files by name pattern."""
11011101

11021102
pattern: str = Field(..., description="`fd`-compatible glob pattern to search for (e.g. '*.py', 'test_*.py')")
1103+
page: int = Field(default=1, description="Page number to return (1-based)")
1104+
files_per_page: int | float = Field(default=10, description="Number of files per page to return, use math.inf to return all files")
11031105

11041106

11051107
class SearchFilesByNameTool(BaseTool):
11061108
"""Tool for searching files by filename across a codebase."""
11071109

11081110
name: ClassVar[str] = "search_files_by_name"
11091111
description: ClassVar[str] = """
1110-
Search for files and directories by glob pattern across the active codebase. This is useful when you need to:
1112+
Search for files and directories by glob pattern (with pagination) across the active codebase. This is useful when you need to:
11111113
- Find specific file types (e.g., '*.py', '*.tsx')
11121114
- Locate configuration files (e.g., 'package.json', 'requirements.txt')
11131115
- Find files with specific names (e.g., 'README.md', 'Dockerfile')
@@ -1118,6 +1120,6 @@ class SearchFilesByNameTool(BaseTool):
11181120
def __init__(self, codebase: Codebase):
11191121
super().__init__(codebase=codebase)
11201122

1121-
def _run(self, pattern: str) -> str:
1123+
def _run(self, pattern: str, page: int = 1, files_per_page: int | float = 10) -> str:
11221124
"""Execute the glob pattern search using fd."""
1123-
return search_files_by_name(self.codebase, pattern).render()
1125+
return search_files_by_name(self.codebase, pattern, page=page, files_per_page=files_per_page).render()

src/codegen/extensions/tools/global_replacement_edit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import difflib
44
import logging
5+
import math
56
import re
67
from typing import ClassVar
78

@@ -103,7 +104,7 @@ def replacement_edit_global(
103104
)
104105

105106
diffs = []
106-
for file in search_files_by_name(codebase, file_pattern).files:
107+
for file in search_files_by_name(codebase, file_pattern, page=1, files_per_page=math.inf).files:
107108
if count is not None and count <= 0:
108109
break
109110
try:

src/codegen/extensions/tools/reflection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def perform_reflection(
188188
# Initialize the LLM
189189
llm = LLM(
190190
model_provider="anthropic",
191-
model_name="claude-3-5-sonnet-latest",
191+
model_name="claude-3-7-sonnet-latest",
192192
temperature=0.2, # Slightly higher temperature for more creative reflection
193193
max_tokens=4000,
194194
)

0 commit comments

Comments
 (0)